What happens if a submodule repo name changes

OK this is kind of an edge case, but if you have a submodule and someone upstream changes it’s name, what should you do?

  1. First you probably want to change the location of the module, so you can now just do a git mv old_name new_name and it will be correct in your directory.
  2. Then inside the submodule, you need to change the origin with git remote remove origin and then add the new location git remote add origin new_name and then the git push should work.
  3. It does look like the .gitmodules doesn’t update correctly , the submodule name is wrong as is the url, although the path is right.
  4. Also the link in .git/config also appears wrong.

This seemed like the two work items. The git submodule init seems to work but it is not clear if is all working.

Overall, it is probably easier just to delete the submodule and start over.

I’m Rich & Co.

Welcome to Tongfamily, our cozy corner of the internet dedicated to all things technology and interesting. Here, we invite you to join us on a journey of tips, tricks, and traps. Let’s get geeky!

Let’s connect