How can I change the remote url of a git submodule without breaking commit history? Currently if I checkout old commits my submodule seems to have the old remote url witch doesn't exist anymore.
My workflow:
Push .gitmodules to remote (Commit C)
Clone repo with commit A,B,C
-> want also the new submodule remote URL, but still the old url in .gitmodules
It seems that git submodule update --init
is still trying to use the old remote url
If have also tried to use git submodule update
, as suggested, but I also got the error:
The Git repository with name or identifier OLD_REPO_NAME does not exist or you do not have permissions for the operation you are attempting.
Let's try another approach. Instead of replacing URLs in the config files replace URLs on the fly:
git config --global url.<NEW-URL>.insteadOf <OLD-URL>
See git help config
about url.<base>.insteadOf
.