We have a git repository that depends on code in other git repositories. We use submodules, the usual way, to express this relationship and ensure that the supporting code lives at a standard location within the user's directory structure. Updating the supporting code is straightforward enough:
The problem comes on the other side. After this sort of change, for other developers to get a complete, consistent set of code they need to execute three commands:
It's proven difficult to train developers to do all of these, particularly since in all of our other repositories, which don't contain submodules, the pull is sufficient. The result is developers at times working with code that uses obsolete versions of the submodules, resulting in spurious problems that can be time-consuming to track down. It there any way, other than writing a shell script that does all three commands and insisting "Use this!", to make this more automatic?
You could try and ask your colleagues to:
git config --global fetch.recurseSubmodules on-demand
From git config man page:
fetch.recurseSubmodules
This option can be either set to a boolean value or to on-demand.
- Setting it to a boolean changes the behavior of fetch and pull to unconditionally recurse into submodules when set to true or to not recurse at all when set to false.
- 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.
The other alternative would be to ask them to do one more complex command:
git pull --recurse-submodules=on-demand
The git config
setting mentioned above has the advantage to allow developers to do a simple git pull
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With