To find the number of commits on a git branch you can do:
$ git rev-list --count HEAD
920
However, if you initially clone with --depth=1
, that doesn't work:
$ git clone https://github.com/ndmitchell/hoogle.git --depth=1
$ cd hoogle
$ git rev-list --count HEAD
1
Is there any way to get the speed and reduced network traffic of a --depth=1
clone, but then also get the count of the number of commits?
Is there any way to get the speed and reduced network traffic of a --depth=1 clone, but then also get the count of the number of commits?
I'm pretty sure you can't.
As you know, --depth=1
only retrieves the most recently pushed commit. That means when you clone with a depth of 1 you get 1 commit and only that single commit, with no history at all attached to it.
As far as your local repository is concerned, there is no history, just this 1 commit.
As is also mentioned in the docs
--depth
Create a shallow clone with a history truncated to the specified number of revisions.
What I also find interesting that even if you'd check the origin
$ git rev-list --count origin/master
$ git log origin/master
they'd both only show 1 commit, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With