Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell the depth of a git repository?

Tags:

git

A script I am debugging is supposed to use --depth 1 when cloning a git repository in order to avoid downloading all its history. However, I suspect it might be buggy and that it is actually performing a full clone.

How can I inspect the resulting repository to determine if it was cloned with --depth 1 or not?

like image 339
hugomg Avatar asked Sep 10 '25 16:09

hugomg


2 Answers

If the contents of .git/shallow are the same as git rev-parse HEAD, the depth is 1.

like image 77
Ry- Avatar answered Sep 13 '25 05:09

Ry-


After you made a shallow clone --depth 1 use

git rev-list --count --all

if it outputs 1 you only have 1 commit in the object database.

Does the script use the --no-single-branch option? This would explain why git fetches multiple commits (each for every branch or tag)

like image 44
René Link Avatar answered Sep 13 '25 05:09

René Link