git常用命令集锦

GIT 分支操作:

列出所有本地分支$: git branch

列出所有远程分支$: git branch -r

列出所有本地和远程分支$: git branch -a

新建分支,依然停留在当前分支$: git branch [branch -name]

新建一个分支,并切换到该分支$: git checkout -b [branch]

新建一个分支,指向指定commit$: git branch [branch] [commit]

新建一个分支,与指定的远程分支建立追踪关系$: git branch --track [branch] [remote -branch]

切换到指定分支,并更新工作区: git checkout [branch -name]

切换到上一个分支$: git checkout -

建立追踪关系,在现有分支与指定的远程分支之间$: git branch --set upstream [branch] [remote - branch]

合并指定分支到当前分支$: git merge [branch]

选择一个commit,合并进当前分支$: git cherry-pick [commit]

删除分支$: git branch -d [branch -name]

删除远程分支$: git push origin --delete [branch -name]
git branch -dr [remote/branch]

代码回退至某个提交点,即代码回滚到某个提交点,不存在提交记录$: git reset --hard [commit]

撤回某次提交记录$: git revert [commit]

猜你喜欢

转载自blog.csdn.net/Karl_ben/article/details/83108398