You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

890 B

+++ title = "Change git submodule URL" summary = """Another thing I forget constantly when using git: Changing the remote URL of a submodule""" date = "2022-12-01T20:08:17+01:00" lastmod = "2022-12-13T06:37:11+01:00" categories = ["computerstuff"] tags = ["git"]

+++

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. And run

    $ git submodule update
    

More complete info can be found elsewhere:

https://stackoverflow.com/questions/913701/changing-remote-repository-for-a-git-submodule