Trident D'Gao
Trident D'Gao

Reputation: 19680

How do I get the differences in the number of commits between one certain branch and all other ones in Git?

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

enter image description here

So my question goes:

Upvotes: 0

Views: 33

Answers (2)

LeGEC
LeGEC

Reputation: 51780

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.

Upvotes: 1

gzh
gzh

Reputation: 3596

Combined with wc command will give you the commit count.

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

Upvotes: 0

Related Questions