Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I count number of commits between two branches?

Tags:

git

Using the git diff --shortstat my_branch master is a great way to tell how many files changes and the insertions and deletions. I read the git diff documentation, but I couldn't find a way to tell the number of commits between my_branch and master. Does that exist?

like image 457
nickcoxdotme Avatar asked Oct 16 '14 20:10

nickcoxdotme


People also ask

How do I find commits between two branches?

In order to see the commit differences between two branches, use the “git log” command and specify the branches that you want to compare. Note that this command won't show you the actual file differences between the two branches but only the commits.

How can I see how many commits I have in git?

Show activity on this post. This gives me an exact count of commits in the current branch having its base on master. The command in Peter's answer, git rev-list --count HEAD ^develop includes many more commits, 678 vs 97 on my current project.

Can a commit be on more than one branch?

Merge branches Merging your branch into master is the most common way to do this. Git creates a new commit (M) that is referred to as a merge commit that results from combining the changes from your feature branch and master from the point where the two branches diverged.


1 Answers

I think you could try:

git log --oneline mybranch ^master

For the exact count:

git log --oneline mybranch ^master | wc -l

Should give you the information you want.

like image 186
Daniel Williams Avatar answered Oct 03 '22 10:10

Daniel Williams