DEV Community

How to count the number of commits made between 2 commits hashes

Espoir Murhabazi on May 20, 2019

The problem You have been working hard on that feature for many days and now it's done. Unfortunately, you have made a lot commit and yo...
Collapse
 
paesibassi profile image
Federico Calore • Edited

You can pass the output of the wc command to sed to remove the any whitespace.
This should work:

git rebase -i HEAD~"$(git rev-list 33b14c62b...33ad6cecf | wc -l | sed 's/ //g')"

Collapse
 
espoir profile image
Espoir Murhabazi

Thanks for this input dear Federico,
Let me try to edit the post

Collapse
 
andy profile image
Andy Zhao (he/him)

Nice post Espoir! Not sure how to combine the two commands into one, but I think it's nice to have it as two commands as well.

Collapse
 
drmahikbov profile image
drmahikbov

Hi thanks really helpful. Could you please show how to make a git alias from this please It would be extremely helpful