git branch -v、git branch -vv、git branch -verbose
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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏