1 查看分支
1.1 查看分支列表 git branch
需要查看每一个分支的最后一次提交,可以运行 git branch -v
命令:
$ git branch -v
iss53 93b412c fix javascript issue
* master 7a98805 Merge branch 'iss53'
testing 782fd34 add scott to the author list in the readmes
--merged
与 --no-merged
这两个有用的选项可以过滤这个列表中已经合并或尚未合并到当前分支的分支
2 新建分支
2.1 git checkout -b 【new branch]
$ git checkout -b iss53
Switched to a new branch "iss53"
它是下面两条命令的简写:
$ git branch iss53
$ git checkout iss53
3 切换分支
git checkout 【branch-name]
4 删除分支
git branch -d [branch-name]
如果分支没有被合并,会有提示,如果强制删除,使用 git branch -D 【branch-name】
5 合并分支
git merge 【branch-name】