The Use Case is that i have to move certain repositories to a new server. So these repositories get a new url.
The Parent project which reference these sub-modules needs to be updated with the new url for the sub-module.
I think of doing the following.
- update the .gitmodules file
- git submodule sync
- git submodule update
- commit and push
But, since the previous commits have the earlier version of the .gitmodule, if i checkout a previous commit of the parent project - will it not look for the old server?
To ensure reproducibility, we need to have all old commits to be working.
Any idea to get around this?
The URL that's in .gitmodules
is generally only used when initializing the submodules or on git submodule sync
. On initialization (git submodule init
), the URL is put into the repository's .git/config
, and when the submodule is cloned into place (on git submodule update
) the URL to use is taken from the config. The only other time the URL in .gitmodules
is used is when you run git submodule sync
, which will similarly update the URL in the config, but also set the origin
remote in the submodule to the same URL.
This means that you won't have any problems with checking out an earlier commit and running git submodule update
- the remote origin
in your submodule isn't changed when you checkout a new commit in the parent repository.
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