threads / discuss / 63359

Shallow checkout of submodules

Subject: Shallow checkout of submodules

## tl;dr

One message between Apr 28, 2025 and Apr 28, 2025.

replies: 0people: 1as markdown or json

Pavel Pavlov· Apr 28, 2025, 04:04 UTC · lore
Hi,

I've noticed that in some cases shallow checkout of submodules checks out the entire history (and takes longer to fetch and make much larger size repo).

I created two repos to show the issue. https://github.com/pps83/submodule-test-ok https://github.com/pps83/submodule-test-bad

Both are effectively identical: a readme file with a shallow submodule. submodule-test-ok links to https://github.com/pps83/brotli-master-min/tree/1e6f9b4b4c98f6f99ba9a860cbb982346631df80 submodule-test-bad links to https://github.com/pps83/brotli-master/tree/1e6f9b4b4c98f6f99ba9a860cbb982346631df80

Note, the hashes are identical (repos are different `brotli-master-min` vs `brotli-master`).

If you checkout submodule-test-bad ``` git clone https://github.com/pps83/submodule-test-bad.git cd submodule-test-bad time git submodule update --progress --init --force cd .. ``` entire `submodule-test-bad` is 34MB and takes a long time to fetch (if you are in some remote location with slow internet).

If you checkout submodule-test-ok ``` git clone https://github.com/pps83/submodule-test-ok.git cd submodule-test-ok time git submodule update --progress --init --force cd .. ``` entire `submodule-test-ok` is only 2.9MB and takes a second to fetch. At the end the only difference is in the `.git` folders, while contents of these two repos are identical.

Not sure if that's a git issue, or github. But the issue happens because of the default branch settings in the repo. In short, shallow checkout of a submodule from a non-default branch on github results in a full checkout.

Thanks, Pavel

← back to recent threads