Git – Number of commits in a git repository


A 5 month project of mine is nearing its end and as a fan of pointless statistics,
I'd like to know how many commits have been made since the repository's inception.

How do I find that out?


  1. I know there is no one repository, I'm just interested in the local version.

  2. This is trivial in subversion, as the revision identifier
    seems to be the commit number.

Best Solution

To get the number of commits on the current branch:

git log --pretty=oneline | wc -l

For a more complete count, use:

git rev-list --all | wc -l

See the docmentation for git rev-list for details on specifying objects to count.

It is tempting to try something like:

find .git/objects -type f | wc -l

but this will not count packed objects. It's best to stick with git rev-list.