Tomas
Tomas

Reputation: 123

.gitmodules options to ignore a submodule in a submodule

I have a git repository with a hierarchy of submodules similar to this:

TopLevelRepo
+- .gitmodules # this is where I want the configuration
+- externals
   +- RepoA # this is a 3rd party repository and I cannot modify it
   |  +- externals
   |     +- RepoB # this repository is not necessary and is very large
   |     +- RepoC # this repository is required
   +- RepoD
   +- dozens more repositories

The way I clone the repository is one of these:

git clone --recursive https://github.com/TopLevelRepo TopLevelRepo
# or
git clone https://github.com/TopLevelRepo TopLevelRepo
cd TopLevelRepo
git submodules update --init --recursive

Is there an option that I can add to .gitmodules (or any other file that is checked into the repository) that would allow me to skip (avoid cloning) the RepoB, but keep the RepoC?

I have already found this: Exclude submodule of a submodule which would apparently do what I want, but I need it to be stored in the top level repository.

Thanks.

Upvotes: -1

Views: 537

Answers (1)

phd
phd

Reputation: 94397

No, the top-level superproject cannot manage subsubmodules, only the immediate parent can. Try something like this:

git clone https://github.com/TopLevelRepo TopLevelRepo
cd TopLevelRepo
git submodules update --init RepoA
cd RepoA
git config submodule.RepoB.update none
cd ../.. # back to TopLevelRepo
git submodules update --init --recursive

Upvotes: 1

Related Questions