0

I am not sure what the right name for the following diagram is, but it can be found

  • on Github:

enter image description here

  • in TFS: enter image description here

So my question goes:

  • Is there a standard command in Git that displays the differences in the number of commits between one certain branch and all other ones?
Trident D'Gao
  • 17,538
  • 18
  • 90
  • 151

2 Answers2

1

This question looks a lot like yours : Show git ahead and behind info for all branches including remotes


I don't know of any standard git command that does this straight away, one command which shows the number of commits between a and b is :

git rev-list --count a..b

I adapted the answer above in this other answer and came up with a script to get the counters for two branches :

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"

usage :

$ ./ahead.sh HEAD origin/master
HEAD (ahead 7) | (behind 0) origin/master

You can adapt it to iterate through all branch heads and compares HEAD to the named branch.

Community
  • 1
  • 1
LeGEC
  • 35,975
  • 2
  • 46
  • 87
0

Combined with wc command will give you the commit count.

git log --oneline branch_a..branch_b | wc -l

gzh
  • 3,291
  • 2
  • 18
  • 21