How to retrieve the number of commits of a Git branch without downloading full commit history

87 Views Asked by At

I need to obtain the commit count from a Git repository. How can I do this with a git command without downloading the entire commit history?

2

There are 2 best solutions below

0
jthill On BEST ANSWER
git clone --bare --filter=tree:0   u://r/l

The main hosting services support filtering, if wherever's hosting your repo doesn't you'll need help from the administrators.

5
dhiaa ben hamadou On

Commit count for one revision (HEAD, master, or commit hash):

git rev-list --count <revision>

Commit count for all branches:

git rev-list --count --all

update: this is for local repositories