joseph.hainline joseph.hainline - 1 year ago 61
Git Question

How do I replace a git submodule with another repo?

How do I replace a git submodule with a different git repo?

Specifically, I have a submodule:

  • located at
    that points to a git repo

  • I'd like it to now point to

The problem is that when I delete the submodule with the method described here, then re-add it using the command

git submodule add

I get this error:

A git directory for 'ExternalFrameworks/TestFramework' is found locally with remote(s):
If you want to reuse this local git directory instead of cloning again from
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.

Answer Source

If the location (URL) of the submodule has changed, then you can simply:

  1. Modify your .gitmodule file to use the new URL
  2. Run git submodule sync

More complete info can be found elsewhere: