How do I replace a git submodule with another repo?

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

  1. Modify the .gitmodules file in the repo root to use the new URL.
  2. Delete the submodule folder in the repo rm -rf .git/modules/<submodule>.
  3. Delete the submodule folder in the working directory rm -rf <submodule>.
  4. Run git submodule sync.
  5. Run git submodule update.

More complete info can be found elsewhere:

Leave a Comment