5

Is there a way to set in .gitconfig to git clone automatically add --recurse-submodules flag ? I trie to add in .gitconfig the following:

[fetch]
    recurseSubmodules = true

But it doesn't work.

$ git clone upstream nowyprojekt2
Cloning into 'nowyprojekt2'...
done.

I need to add the --recurse-submodule flag

$ git clone --recurse-submodule upstream nowyprojekt2
Cloning into 'nowyprojekt2'...
done.
Submodule 'euca2ools' (https://github.com/eucalyptus/euca2ools.git) registered for path 'euca2ools'
Cloning into 'euca2ools'...
remote: Counting objects: 19147, done.
remote: Total 19147 (delta 0), reused 0 (delta 0), pack-reused 19147
Receiving objects: 100% (19147/19147), 22.23 MiB | 450.00 KiB/s, done.
Resolving deltas: 100% (15556/15556), done.
Checking connectivity... done.
Submodule path 'euca2ools': checked out '12c358cd27ff652cb144de124bb5472a74145277'

My GIT version:

$ git --version
git version 2.1.0
mastier
  • 872
  • 1
  • 10
  • 22

3 Answers3

2

No, this is not available, even in the latest Git 2.5 released today.

That leaves you with an alias (or git alias) workaround, in order to replace a git clone --recursive by one command (similar to "Setting git default flags on commands").

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

The currently highest-rated answer is not true anymore, you can indeed set a (global) config to always add --recursive-submodules. Just set it via

git config --global fetch.recurseSubmodules yes

(possible values are yes, no, on-demand, docs are here https://git-scm.com/docs/fetch-options#Documentation/fetch-options.txt---recurse-submodulesyeson-demandno)

  • doesnt work for me git version 2.34.1 https://git-scm.com/docs/fetch-options/2.33.0 Indeed fetching yes, but cloning no First you have to clone the repo, run submodule update --init then git fetch fetches also the submodules – mastier May 30 '23 at 13:23
0

it is possible. git clone takes the --config flag, which initialises the repo with some given config params. you should be able to do git clone --config fetch.recurseSubmodules [my-repo].

user1034533
  • 1,054
  • 9
  • 9