Git找到所有分支的负责人

时间:2019-06-27 12:25:17

标签: git

有可能通过头提交来获取git存储库的所有分支。

如果我有以下存储库:

* b562239 (HEAD -> master) lastCommit
* 3828834 (seccondBranch) seccond Commit 
| * 3f6fdf6 (firstBranch) branchCommit
|/  
* b051ccd init repo

我想要这样的列表:

master b562239
seccondBranch 3828834
firstBranch 3f6fdf6

1 个答案:

答案 0 :(得分:3)

裁判的管道工具是git for-each-ref

git for-each-ref --format='%(refname:short) %(objectname:short)' refs/heads

获得所需的确切输出。


同样值得注意的是,git branch -v(或-vv的详细程度稍高)将列出所有分支,并将其尖端指向其提交哈希值,但以一种非常冗长的方式,因为它还具有信息关于远程分支机构关联/上次提交消息。

使用-v的分支的示例输出:

development    f06f99b5c4 [behind 1] <commit message of commit f06f99b5c4>

使用-vv的分支的示例输出:

development    f06f99b5c4 [origin/development: behind 1] <commit message of commit f06f99b5c4>
相关问题