如何在 Git 中获取分支负责人的列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8201765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 12:22:06  来源:igfitidea点击:

How to get list of branch heads in Git?

git

提问by Tower

I am trying to get a list of branch heads in Git. So far I have found git log --simplify-by-decorationwhich seems to include all branches and show the heads, but it also shows one extra commit which is useless for me. Is there an even better way to do this or is that what I should use?

我正在尝试获取 Git 中的分支负责人列表。到目前为止,我发现git log --simplify-by-decoration它似乎包含所有分支并显示头部,但它也显示了一个对我无用的额外提交。有没有更好的方法来做到这一点,还是我应该使用的?

So to make it clear: I want to have an output that gives me the head of all branches in my local repository. Basically, I just need the hash of each of the heads, but I can just regex it from whatever output I get.

所以要说清楚:我想要一个输出,让我知道本地存储库中所有分支的负责人。基本上,我只需要每个头的散列,但我可以从我得到的任何输出中对其进行正则表达式。

回答by loganfsmyth

You should be able to use the git show-refcommand. git-show-ref docs

您应该能够使用该git show-ref命令。git-show-ref 文档

git show-ref --heads -s