Find the number of commits in the Git repository when cloning with --depth = 1

To find the number of commits on a git branch, you can do:

$ git rev-list --count HEAD 920 

However, if you originally cloned using --depth=1 , this does not work:

 $ git clone https://github.com/ndmitchell/hoogle.git --depth=1 $ cd hoogle $ git rev-list --count HEAD 1 

Is there a way to get the speed and reduced cloning network traffic --depth=1 , but then also get a count of the number of commits?

+4
source share
1 answer

Is there a way to get speed and reduced network traffic -depth = 1 clone, but then also get a count of the number of commits?

I am sure you cannot.

As you know, --depth=1 retrieves only the last message clicked. This means that when cloning with a depth of 1, you get 1 commit and only one commit without binding the story to it.

As for your local repository, the story does not exist, it's just 1 commit.

As also mentioned in docs

- depth

Create a shallow clone with a story truncated to the specified number of revisions .

Which is also interesting to me, even if you checked the origin

 $ git rev-list --count origin/master $ git log origin/master 

they will both show only 1 commit too.

+2
source

All Articles