Sometimes, it’s inevitable (maybe? :) ), you’ll add a git submodule from the wrong URL… I mean, EVERYONE’S done that, right? … right? you lot over there, am I right?… SIGH.
In my case, I’m trying to make sure I always use the https URLs with my github repo, but sometimes I add the git URL instead. When you run
git remote -v in the path, you’ll get something like:
origin firstname.lastname@example.org:your-org/your-repo.git (fetch)
origin https://github.com/your-org/your-repo (fetch)
which means that when someone tries to clone your repo, they’ll be being asked for access to their public keys for all the submodules. Not great
Anyway, it should be easy enough – git creates a .gitmodules file in the repo root, so you should just be able to edit that file, and replace the
https:// and the
com/… but what do you do next?
Thanks to this great Stack Overflow answer, I found you can just run these two commands after you’ve made that edit:
git submodule sync ; git submodule update --init --recursive --remote
Isn’t Stack Overflow great?