一些常用到的git命令

git stash -a //缓存所有文件

git checkout -b dev origin/dev //切换到dev分支上,接着跟远程的origin地址上的dev分支关联起来

//推送本地分支到远程仓库

git push origin localbranchname:remotebrancname

git revert onefile //https://www.freecodecamp.org/news/git-revert-file-reverting-a-file-to-a-previous-commit/

//Git中获取当前分支名git

git branch --show-current

//git从指定的commit创建分支

git checkout -b branchname <commit-hash>

//以下两个命令需要在git bash下执行,因为window下找不到grep\xargs命令

//This script will delete all local branches except the master branch, including the non-merged branches.

git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main\|develop" | xargs git branch -D

//The -d is a soft delete option and only removes the merged branches.

git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main\|develop" | xargs git branch -d

//合并某个提交

git cherry-pick <commit-hash>

//列出包含某个提交的所有标签

git tag --contains f3a0b78

//克隆某个Tag的代码

git clone -b v9.2.2 https://gitlab.kitware.com/vtk/vtk.git

//回滚到某个提交

git log --oneline

git reset --hard <commit-hash>

git checkout -b branchname

git push origin localbranchname:remotebranchname

相关推荐
上单带刀不带妹3 小时前
Git rm 命令与系统 rm 命令的区别详解
git
我的收藏手册6 小时前
性能监控shell脚本编写
前端·git·github
Yvonne爱编码8 小时前
简述ajax、node.js、webpack、git
前端·git·ajax·webpack·node.js·visual studio
2501_9200470321 小时前
git在Linux中的使用
linux·git·elasticsearch
小马哥编程1 天前
DNS解析中的服务器协作机制
服务器·git·github
白帽小野1 天前
SVN和Git两种版本管理系统对比
git·svn·版本控制系统
rivercoder1 天前
Gitea:轻量级的自托管Git服务
git·gitlab·gitea
呜喵王阿尔萨斯2 天前
git命令解析
c++·git
Doris_LMS3 天前
Git的强软硬回退(三)
运维·服务器·数据库·git·idea
瓜酷月..3 天前
GIT(了解)
git