2

It seems like by design git's submodule operations are manual. As a moderately-adept git user, I want to understand this design decision. In particular, it seems like the least surprising thing for git pull or git checkout to do is to check pull/check out the appropriate branch/comment, then update all submodules to match their corresponding commits. Why?

It appears that the above functionality is enabled if I set

[submodule]
        recurse = true

in my ~/.gitconfig. But even then, when a colleague adds a new module, when I git pull master, I don't get the new module even though it shows up in .gitmodules. If I check .gitmodules for new ones and then do git submodule update --init MODULEPATH, I get it. But again, why would this manual interaction be the desired behavior? When I pull/checkout, wouldn't I (almost?) always want all the modules update to match?

Bonus: Is there a way to automatically have git fetch and check out new submodules? I.e., is there a Just Works mode for submodules. And if not, what do I not understand about the design of submodules that makes the default behavior desirable?

Ben
  • 9,184
  • 1
  • 43
  • 56
  • *I want to understand design decisions* and *why would this manual interaction be the desired behavior?* are hardly suitable questions for StackOverflow. See https://stackoverflow.com/help/dont-ask – phd Jan 23 '19 at 14:56
  • *Is there a way to automatically have git fetch and check out new submodules?* [Yes](https://stackoverflow.com/a/50178825/7976758). See https://stackoverflow.com/search?q=%5Bgit-submodules%5D+switch+branches+hook – phd Jan 23 '19 at 15:00
  • I understand why it's not a great question. I posed it this way because after much searching, I felt like I was finding some partial answers to my practical question, but no overarching explanation why I was just not groking the default behavior. – Ben Jan 23 '19 at 16:03
  • 1
    https://stackoverflow.com/a/1899826/7976758 – phd Jan 23 '19 at 16:14

0 Answers0