Git分支管理-查看分支
        
 # Git分支管理-查看分支
# 查看分支
$ git branch
  iss53
* master  # 带星号*表示当前所在分支
  testing
 1
2
3
4
2
3
4
git branch 命令不只是可以创建与删除分支。 如果不加任何参数运行它,会得到当前所有分支的一个列表。
# 查看每个分支的最后提交
$ git branch -v
  iss53   93b412c fix javascript issue
* master  7a98805 Merge branch 'iss53'
  testing 782fd34 test
 1
2
3
4
2
3
4
# 查看已(未)合并的分支
--merged 与 --no-merged 这两个选项可以查看哪些分支已经合并或未合并到 当前 分支。
$ git branch --merged # 查看已合并分支列表
  iss53
* master
 1
2
3
2
3
上面列表中分支名字前没有 * 号的分支通常可以使用 git branch -d 删除掉;
$ git branch --no-merged # 查看未合并的分支列表
  testing
 1
2
2
上面显示未合并的分支,尝试使用 git branch -d 命令删除它时会失败:
$ git branch -d testing
error: The branch 'testing' is not fully merged.
If you are sure you want to delete it, run 'git branch -D testing'.
 1
2
3
2
3
强制删除未合并的分支:
$ git branch -D testing
 1
# 查看指定分支的已(未)合并的分支
上面描述的选项 --merged 和 --no-merged 会在没有给定提交或分支名作为参数时, 分别列出已合并或未合并到 当前 分支的分支。
你总是可以提供一个附加的参数来查看其它分支的合并状态而不必检出它们。 例如,尚未合并到 testing 分支的有哪些?
$ git branch --no-merged testing
  topicA
  featureB
 1
2
3
2
3
上次更新: 2022/03/05, 15:57:30
- 01
 - 009-Palindrome Number[回文数]03-10
 
- 02
 - 008-String to Integer (atoi)[字符串转整数]03-10
 
- 03
 - 004-Reverse-integer[整数反转]03-09