git submodule update has supported the --depth option as described in this answer.
But still we can't easily determine the depth value, which would probably make git unable to find the intended revision of a submodule.
Is there a true solution for updating submodules shallowly?
So I think the exact depth would still be a myth, which is the only and must be resolved concern of the question
While there is indeed no "exact depth", you can still record a "depth recommendation" with git 2.9.x+ (Q3 2016).
See commit abed000, commit 37f52e9 (26 May 2016) by Stefan Beller (stefanbeller).
(Merged by Junio C Hamano -- gitster -- in commit 3807098, 20 Jun 2016)
submodule update: learn--[no-]recommend-shallowoption
An upstream project can make a recommendation to shallowly clone some submodules in the
.gitmodulesfile it ships.
Sometimes the history of a submodule is not considered important by the projects upstream.
To make it easier for downstream users, allow a boolean field 'submodule.<name>.shallow' in.gitmodules, which can be used to recommend whether upstream considers the history important.
This field is honored in the initial clone by default, it can be ignored by giving the
--no-recommend-shallowoption.
That way, a simple git submodule update (no additional parameters) will use the recommended depth value, if found.
See also "Git submodule without extra weight" with:
git config -f .gitmodules submodule.<name>.shallow true
g19fanatic proposes in the comments:
quick 1-liner to add
shallow=trueto all submodules:git submodule | awk '{print $2}' | \ xargs -n 1 -I %% bash -c 'git config -f .gitmodules submodule.%%.shallow true'or, with
git submodule foreach:git submodule foreach 'git config -f .gitmodules submodule.$sm_path.shallow true'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With