I've created a git repository with a submodule in it. I'm able to tell the submodule itself to change its remote repository path, but I'm not sure how to tell the parent repository how to change the remote repository path for the submodule.
I wouldn't be surprised if I'm somewhat out of luck and have to do things manually, as even deleting submodules isn't easy.
Actually, a patch has been submitted in April 2009 to clarify
gitmodule
role.So now the gitmodule documentation does not yet include:
That pretty much confirm Jim's answer.
If you follow this git submodule tutorial, you see you need a "
git submodule init
" to add the submodule repository URLs to .git/config."
git submodule sync
" has been added in August 2008 precisely to make that task easier when URL changes (especially if the number of submodules is important).The associate script with that command is straightforward enough:
The goal remains:
git config remote."$remote".url "$url"
In simple terms, you just need to edit the .gitmodules file, then resync and update:
Edit the file, either via a git command or directly:
or just:
then resync and update:
You should just be able to edit the
.gitmodules
file to update the URL and then rungit submodule sync
to reflect that change to the superproject and your working copy.These commands will do the work on command prompt without altering any files on local repository
Please look at the blog for screenshots: Changing GIT submodules URL/Branch to other URL/branch of same repository
What worked for me (on Windows, using git version 1.8.3.msysgit.0):
git submodule init
andgit submodule update
After doing all that, everything is in the state I would expect. I imagine other users of the repository will have similar pain when they come to update though - it would be wise to explain these steps in your commit message!
Just edit your .git/config file. For example; if you have a "common" submodule you can do this in the super-module: