I have a Git project which has a submodule. The url of the submodule was recently changed. I have changed the .gitmodules and config file to point to the new url. Should I commit the .gitmodules file so that the next time I checkout my project and do  git submodule update --init --recursive I won't get an error?
Nobody speaks about how and what files one has to commit
No need to change a file, sync/commit: this is now done for you in one new command.
With Git 2.25 (Q1 2020), "git submodule" learned a subcommand "set-url".
See commit 26b0610 (29 Oct 2019) by Denton Liu (Denton-L).
(Merged by Junio C Hamano -- gitster -- in commit 99c4ff1, 10 Dec 2019)
submodule: teach set-url subcommandSigned-off-by: Denton Liu
Currently, in the event that a submodule's upstream URL changes, users have to manually alter the URL in the
.gitmodulesfile then rungit submodulesync.
Let's make that process easier.Teach submodule the
set-urlsubcommand which will automatically change thesubmodule.$name.urlproperty in the.gitmodulesfile and then rungit submodulesyncto complete the process.
The git submodule documentation now includes:
set-url [--] <path> <newurl>:Sets the URL of the specified submodule to
<newurl>.
Then, it will automatically synchronize the submodule's new remote URL configuration.
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