How do I replace a git submodule with a different git repo?
Specifically, I have a submodule:
./ExternalFrameworks/TestFramework
that points to a git repo git@github.com:userA/TestFramework.git
git@github.com:userB/TestFramework.git
.The problem is that when I delete the submodule with the method described here, then re-add it using the command
git submodule add git@github.com:userB/TestFramework.git
I get this error:
A git directory for 'ExternalFrameworks/TestFramework' is found locally with remote(s):
origin git@github.com:userA/TestFramework.git
If you want to reuse this local git directory instead of cloning again from
git@github.com:userB/TestFramework.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
If the location (URL) of the submodule has changed, then you can simply:
.gitmodules
file in the repo root to use the new URL.rm -rf .git/modules/<submodule>
.rm -rf <submodule>
.git submodule sync
.git submodule update
.More complete info can be found elsewhere: