Skip to content
Go back

git commit count

Published:  at  11:37 AM
1 min read

I have a tendency of creating many small commits when working on a new feature.

While this may have some advantages, like ease of review, clear context and quick fallbacks, I find myself in need of squashing these commits before the actual merge.

In order to use git’s interactive rebase to rearrange my commits[1], I need to find out the number of relevant commits.

Sure, I can use tig or git log --pretty=oneline and simply count them, but where’s the fun in that?

Count commits

Today I learned how to count commits between different branches AWA within a branch.

# of commits between master and the current branch:

$ git rev-list --count master..HEAD

[1] $ git rebase -i HEAD~<number-of-commits>




Previous Post
Pretty Please
Next Post
JS Required Params