2

I have a submodule who's submodules I don't need. For example:

mainProject
  - usefulSubmodule
    - notNeededSubmodule

So in mainProject, I define my .gitmodules like so:

[submodule "usefulSubmodule"]
    path = lib/usefulSubmodule
    url = https://whatever
    fetchRecurseSubmodules = false

Then I run git submodule update --init --recursive after updating, and it seems that this is ignoring the value of fetchRecurseSubmodules (which I guess may be true according to the documentation https://git-scm.com/docs/gitmodules#Documentation/gitmodules.txt-submoduleltnamegtfetchRecurseSubmodules )

So therefore my question is, how do I disable this behavior without overriding it during update? What is the best way to update all my submodules while respecting that flag?

yano
  • 4,095
  • 3
  • 35
  • 68
  • 2
    ... run `git submodule update init` without `--recursive`? (Presumably you'll then need to set `fetchRecurseSubmodules = true` in any submodules where you *do* want the recursion.) – torek Oct 15 '19 at 23:14
  • 1
    Exactly. The docs do point out that a nonspecific update updates all the .gitmodules submodules, you've simply imagined the need for that option here. – jthill Oct 15 '19 at 23:21
  • ah perhaps I'm missing something. So is `on-demand` the default for this property if it is not present? – yano Oct 15 '19 at 23:27
  • There's a lot of [new knobs](https://stackoverflow.com/a/69322941/5994170) since 2.34. – mirh Jun 04 '22 at 09:40

1 Answers1

2

So is on-demand the default for this property if it is not present?

Yes, that is what git config fetch.recurseSubmodules specifies:

When set to on-demand (the default value), fetch and pull will only recurse into a populated submodule when its superproject retrieves a commit that updates the submodule’s reference.

Note: if you want to override locally (for just one command) a configuration:

git -c fetch.recurseSubmodules=on-demand submodule update --init

But in this case, it is not needed (this is just to illustrate how one can set a config for one git command)

yano
  • 4,095
  • 3
  • 35
  • 68
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250