1 查看分支

链接

1.1 查看分支列表 git branch

需要查看每一个分支的最后一次提交,可以运行 git branch -v 命令:

  1. $ git branch -v
  2. iss53 93b412c fix javascript issue
  3. * master 7a98805 Merge branch 'iss53'
  4. testing 782fd34 add scott to the author list in the readmes

--merged--no-merged 这两个有用的选项可以过滤这个列表中已经合并或尚未合并到当前分支的分支

2 新建分支

2.1 git checkout -b 【new branch]

  1. $ git checkout -b iss53
  2. Switched to a new branch "iss53"
  3. 它是下面两条命令的简写:
  4. $ git branch iss53
  5. $ git checkout iss53

3 切换分支

git checkout 【branch-name]

4 删除分支

git branch -d [branch-name]
如果分支没有被合并,会有提示,如果强制删除,使用 git branch -D 【branch-name】

5 合并分支

git merge 【branch-name】