git文檔
git branch
-v
-vv
--verbose
When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any). If given twice, print the name of the upstream branch, as well (see also git remote show <remote>).
翻譯說明
顯示每個(本地)分支當前指向的提交記錄的哈希值,以及和其上游分支的相對位置(如果有的話)
-v
與-verbose
是一個效果
-vv
會顯示上游分支的名字
舉例
$ git branch -vv
cyr_branch 689c970 [origin/cyr_branch: behind 2] default
* master f1e2810 finally
test-mysql e2fa7b9 add .gitignore
test-network 0d426ce add .gitignore
xu_branch e55fcf1 [origin/xu_branch: ahead 1] debug
zfc_branch e4a40a5 [origin/zfc_branch] merge
cyr_branch
的上游分支為origin/cyr_branch
,前者落后后者2
xu_branch
的上游分支為origin/xu_branch
,前者領先后者1
zfc_branch
的上游分支為origin/zfc_branch
,兩者同步
test-mysql
和test-network
沒有對應的上游分支
master
的上游分支為origin/master
,但是沒有顯示,我猜測是因為這個對應關系是固定的,所以無需顯示
組合用法
-a 顯示所有本地及遠端分支名
$ git branch -a
cyr_branch
* master
test-mysql
test-network
xu_branch
zfc_branch
remotes/origin/cyr_branch
remotes/origin/master
remotes/origin/xu_branch
remotes/origin/zfc_branch
-av
$ git branch -av
cyr_branch 689c970 [behind 2] default
* master f1e2810 finally
test-mysql e2fa7b9 add .gitignore
test-network 0d426ce add .gitignore
xu_branch e55fcf1 [ahead 1] debug
zfc_branch e4a40a5 merge
remotes/origin/cyr_branch 1e63522 cyr
remotes/origin/master f1e2810 finally
remotes/origin/xu_branch 1c82da3 adjust db
remotes/origin/zfc_branch e4a40a5 merge
-avv
$ git branch -avv
cyr_branch 689c970 [origin/cyr_branch: behind 2] default
* master f1e2810 finally
test-mysql e2fa7b9 add .gitignore
test-network 0d426ce add .gitignore
xu_branch e55fcf1 [origin/xu_branch: ahead 1] debug
zfc_branch e4a40a5 [origin/zfc_branch] merge
remotes/origin/cyr_branch 1e63522 cyr
remotes/origin/master f1e2810 finally
remotes/origin/xu_branch 1c82da3 adjust db
remotes/origin/zfc_branch e4a40a5 merge