tags:

views:

269

answers:

4

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?

Notes:

  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.

+9  A: 

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.

William Pursell
Thanks, git gurus. I know this wasn't the first wc -l solution, but the fact that this looks at the current branch is good to know.
Rhythmic Fistman
And of course you can count number of commits since some revision with e.g. "git rev-list v0.9.. | wc -l". And there is also git-shortlog (see its documentation).
Jakub Narębski
+3  A: 

There may be a more elegant way to do it, but I would just run:

git log --pretty=oneline | wc -l
Anirvan
+1  A: 

Just run 'gitk'. It will also show the number of commits on the screen.

Rutger Nijlunsing
+2  A: 

Others have already posted the easiest answers but here are a couple of options that might also be of interest.

Easy Git is a simple, light-weight wrapper (single file perl script) for Git. One nice feature that it adds to Git is an "info" command (run: eg info) that gives some nice info about your repository, including the number of commits, files, directories, contributors and largest file.

GitStats is another tool that gives you all kinds of nice plots of statistics about your repository. Checkout their examples, e.g., an analysis of the git project.

Pat Notz