Number of commits in a git repository
$ git shortlog -s # or git shortlog -s -n 2 Adam Jacob 2 Matt Ray 19 Mike Adolphs 151 John Jackson 36 jtimberman 2 mattray 4 bkilroy
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.
There may be a more elegant way to do it, but I would just run:
git log --pretty=oneline | wc -l
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.