简体   繁体   中英

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?

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.

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.


$ 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

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 , eg, an analysis of the git project .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM