Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number of commits in a git repository

Tags:

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.

like image 354
Rhythmic Fistman Avatar asked Jul 29 '09 10:07

Rhythmic Fistman


People also ask

How do I see all commits on a repository?

On GitHub, you can see the commit history of a repository by: Navigating directly to the commits page of a repository. Clicking on a file, then clicking History, to get to the commit history for a specific file.

How many commits can git handle?

1 accepted. Hi @Diliup-G , We don't have a limit on the number of commits per repository.


1 Answers

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.

like image 171
William Pursell Avatar answered Nov 02 '22 05:11

William Pursell