Git submodule shallow
Git projects using submodules can be set to default shallow Git clone submodules to save space and time. Edit the “.gitmodules” file to have the “shallow = true” option for each Git submodule. This is particularly useful when the top-level project uses third party libraries or libraries with a large Git revision history.
Example .gitmodules file with shallow Git submodules:
[submodule "proj1"]
path = proj1
url = https://github.invalid/nobody/proj1
shallow = trueThen Git clone with the --recurse-submodules option or Git submodule update with the --init --recursive options:
git clone --recurse-submodules <url>or if already Git cloned
git submodule update --init --recursiveperforms a shallow clone of the Git submodules.
Confirm that the submodules are shallow cloned by checking the Git log of the submodule:
git -C ./proj1 rev-parse --is-shallow-repositoryThese each return “true” indicating that the submodule is shallow cloned.