Could anyone help me please. I want to move some Git repositories from one server to another, and rename them at the same time. The problem I'm having is when some repositories are submodules of other repositories. I want to replace the URL of the submodule throughout the history of all the branches within the top level module so that once the originals have been deleted I can still go back and rebuild an old commit. I'm on a Windows PC and, at the moment, I'm using a .bat file to run my repository migrations.
To move the submodule from server1 to server2 and change the name from sub_old to sub_new I clone the original (bare) into a folder on my C: drive, change the URL and then push up to the new server:
git clone --bare https://server1/sub_old.git c:\temp_repo
cd c:\temp_repo
git remote set-url origin https://server2/sub_new.git
git push --mirror
then delete sub_old from server1.
Now when I want to move a top level repo, which uses the sub_old repo as a submodule, to the new server:
git clone --bare https://server1/top_old.git c:\temp_repo
cd c:\temp_repo
git remote set-url origin https://server2/top_new.git
REM At this point I want to change all of the references to the submodule from https://server1/sub_old.git to https://server2/sub_new.git
git push --mirror
then delete top_old from server1.
At the point where I want to change all of the URL references to the submodule, I've tried using:
git config --global url.https://server2/sub_new.git.insteadOf https://server1/sub_old.git
but with no success. I clearly don't understand how this is supposed to work, or whether it's the appropriate thing to be using.