# Shallow checkout of submodules

1 messages from 2025-04-28 to 2025-04-28. Participants: Pavel Pavlov.
Thread: https://gitlist.dev/t/63359

## Pavel Pavlov, 2025-04-28 04:04

Subject: Shallow checkout of submodules
Message-ID: <CAG_s-qqdzzB=ft4ibymVNfx8o0puFDTOnuwtHrvwgEyUP8Mfig@mail.gmail.com>
URL: https://gitlist.dev/e/CAG_s-qqdzzB%3Dft4ibymVNfx8o0puFDTOnuwtHrvwgEyUP8Mfig%40mail.gmail.com

```
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

```
