There are too many submodule in .gitsubmodule, and downloading all of them will take a lot of time. How can I choose to download only the modules I need.
Asked
Active
Viewed 507 times
1 Answers
0
One option would be to configure the update
setting to none
for the submodules you don't want to update.
But that would only affect the git submodule update
command.
A better option would be to declare those submodules not active.
See "ACTIVE SUBMODULES"
[submodule]
active = b*
active = :(exclude) baz
In here all submodules except
baz
(foo
,bar
,bob
) are active.
foo
due to its own active flag and all the others due to the submodule active pathspec, which specifies that any submodule starting withb
exceptbaz
are also active, regardless of the presence of the.url
field.
That is, however, a local option, since the repository Git configuration is not itself versioned.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
Note however that setting a submodule as inactive is not something you can do in `.gitmodules`, so it would not prevent `git clone --recurse-submodules` from cloning them. – philb Sep 05 '21 at 22:40
-
Also, as of Git 2.33 `git checkout` never clones nor fetches submodules (not sure what you meant by "download"). – philb Sep 05 '21 at 22:42
-
@philb Good point. I have edit my answer to include that caveat. – VonC Sep 06 '21 at 06:21