Skip to content

Made all submodules shallow

Konrad Botor requested to merge kbotor/shallow-submodules into develop

This merge request configures all submodules to be shallow.

As far as I can tell, the only practical difference this makes is that git fetch inside the submodule works like git fetch --depth=1 and that commit history is not present. This in turn means that while checking out branches and tags (whether by name or hash) works as usual, checking out an arbitrary commit requires:

git fetch origin [commit-sha]
git checkout [commit-sha]

instead of

git fetch
git checkout [commit-sha]

In the past this meant that if a submodule pointed to a commit that was not a tip of a branch or a tag, initializing the repository would fail (see https://marc.info/?l=git&m=151863590026582&w=2 for details). I couldn't reproduce this behavior with our GitLab instance and an up-to-date Git, so I'm assuming it has been fixed since.

This change does not seem to affect existing local repositories - that is pulling the change and running git submodule update --init --recursive does not appear to make the submodules shallow.

Finally, it can be easily overridden when setting up a local repository:

git clone --branch kbotor/shallow-submodules git@gitlab.syncad.com:hive/hive.git
cd hive
git submodule update --init --recursive --no-recommend-shallow
Edited by Konrad Botor

Merge request reports