git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Shallow checkout of submodules

From
PPPavel Pavlov <pavlov.pavel@gmail.com>
Date
Apr 28, 2025, 04:04 UTC
Message-ID
<CAG_s-qqdzzB=ft4ibymVNfx8o0puFDTOnuwtHrvwgEyUP8Mfig@mail.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

Message 1 of 1 in “Shallow checkout of submodules”
  1. Pavel PavlovApr 28, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.