Reputation: 1434
I have a git project that I'd like to clone and update submodules on. I clone the project with
git clone --single-branch -b my_branch ssh://my_repo my_repo
I can init and pull submodules with
git submodule init
git submodule update
The problem I'm having is that all repository's git history (~ 1.3Gb) is being pulled with the update on each submodule. My .gitmodules
file looks like
[submodule "mod_1"]
path = path/to/mod_1
url = my_repo
branch = mod_1_branch
[submodule "mod_2"]
path = path/to/mod_2
url = my_repo
branch = mod_2_branch
In the git clone
command above I use --single-branch
option which resolves the problem for the whole repository. As far as I know this option is not available for git submodule update
.
How can I restrict submodules to pull only their branch history? Could there be an appropriate custom command (as described here under update
> custom command
)?
Upvotes: 1
Views: 71
Reputation: 2304
Unfortunately at the moment you cannot shallow fetch (git fetch --depth=1
) a specified commit object.
However in Git 2.5+ (Q2 2015), fetching a single commit (without cloning the full repo) will be possible, through the new server-side config uploadpack.allowReachableSHA1InWant
.
Its documentation says:
uploadpack.allowReachableSHA1InWant::
Allow
upload-pack
to accept a fetch request that asks for an
object that is reachable from any ref tip. However, note that
calculating object reachability is computationally expensive.
Defaults tofalse
.
For more details see Pull a specific commit from a remote git repository.
Upvotes: 1