Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the drawbacks to setting git's submodule.recurse config option to true?

This question Is there a way to make git pull automatically update submodules? has an accepted answer of configuring git like so:

git config --global submodule.recurse true

Like one of the comments to that answer, I'm wondering why this isn't the default behavior of git; more precisely, what are the drawbacks of setting this configuration option?

like image 923
Michael Burr Avatar asked Nov 28 '18 07:11

Michael Burr


People also ask

What does recurse submodules mean?

If you pass --recurse-submodules to the git clone command, it will automatically initialize and update each submodule in the repository, including nested submodules if any of the submodules in the repository have submodules themselves.

Are git submodules a good idea?

Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.

What is a dirty submodule?

In the context of the ignore = dirty setting for submodules, this means that if the submodule is dirty (i.e. if it has tracked files with modifications that have not been committed, and/or new untracked files), such changes will be ignored.

Do submodules update automatically?

Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated. When adding a submodule to a repository a new . gitmodules file will be created.


1 Answers

I have two reasons why lately I reverted to back to recurse=false:

  • I have submodules (3rd party libraries from github) that my project needs, but they have their submodules that I don't need. Namely - several instances o gtest. I don't build tests for 3rd party libraries so fetching them is waste of time and space
  • I had problems if submodule remote changed in repo. This happens usually when I decide that library needs some modification and pushing to upstream is infeasible. I didn't really investigate it as it is always easier to clone from scratch than mess with submodules. recurse=false seems to have mitigated it, but again: I didn't investigate the problem fully.
like image 100
MateuszL Avatar answered Sep 29 '22 12:09

MateuszL