git list remote branches, order by number of commits

There is git branch -r to list all remote branches.

I wonder if there is away to list all remote branches, but order them by number of commits (eg., the branch with most commits is listed first).


I guess one usage is that it can filter out unused/obsolete branches (that have very commits) and tidy up the repo

That is what you see in the "branches" tab section of a GitHub project:

Example for git/git/branches:

GIT中/ GIT中/分支

What you want is not the number of commits, but, for a given branch acting as reference, the number of commit ahead and behind that branch.

git rev-list --left-right --count master...test-branch

That way you can see the one behind that could be safely removed.
Note that you can already list those merged branches with:

git branch --merged master

With Git 2.5, you can also list local branches compared to their remote tracking branches (not your case, but can be useful):

git fetch
git for-each-ref --format="%(push:track)" refs/heads
链接地址: http://www.djcxy.com/p/26062.html

上一篇: Github按合并日期搜索PRS

下一篇: git列表远程分支,按提交数量排序