答案 0 :(得分:1)
这个问题看起来很像你的问题:Show git ahead and behind info for all branches including remotes
我不知道任何直接执行此操作的标准git命令,一个显示a
和b
之间提交次数的命令是:
git rev-list --count a..b
我在this other answer中修改了上面的答案,并提出了一个脚本来获取两个分支的计数器:
file ./ahead.sh :
#!/bin/bash
left=$1
right=$2
leftahead=`git rev-list --count $right..$left`
rightahead=`git rev-list --count $left..$right`
echo "$left (ahead $leftahead) | (behind $rightahead) $right"
用法:
$ ./ahead.sh HEAD origin/master
HEAD (ahead 7) | (behind 0) origin/master
您可以调整它以遍历所有分支头并将HEAD与命名分支进行比较。
答案 1 :(得分:0)
结合wc命令将为您提供提交计数。
git log --oneline branch_a..branch_b | wc -l </ p>