有gitbranch -r
来列出所有远程分支。
我想知道是否可以列出所有远程分支,但按提交次数对它们进行排序(例如,首先列出提交次数最多的分支)。
最佳答案
I guess one usage is that it can filter out unused/obsolete branches (that have very commits) and tidy up the repo
这就是您在 GitHub 项目的“分支”选项卡部分中看到的内容:
git/git/branches 的示例:
您想要的不是提交数量,而是对于作为引用的给定分支,the number of commit ahead and behind that branch .
git rev-list --left-right --count master...test-branch
这样你就可以看到后面的那个可以安全地移除。
请注意,您已经可以 list those merged branches与:
git branch --merged master
With Git 2.5 ,您还可以列出本地分支与远程跟踪分支的比较(不是您的情况,但可能很有用):
git fetch
git for-each-ref --format="%(push:track)" refs/heads
关于git 列出远程分支,按提交数量排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39791019/