Changing the GitHub URL for git submodules

After reading the warning here about changing submodule URLs, I was worried about changing the URL for a git submodule from git://github.com/... to git@github.com:... (i.e., from my public clone URL on Github to my clone URL.)

Initially, I thought it would be a good idea to only clone the shared module in one place and update it from there and simply initialize the submodules from the public (read-only) URL. Quickly, I discovered that this was less than ideal. It's very convenient to be able to update the submodule from within any project, test it, and then commit and push your changes (either that or it's a pretty good code smell that my submodule could do with some unit tests!)

Anyway, I decided to try it out and simply the changed the url in the .gitmodules file for the project and in the .git/config file for the submodule and it worked beautifully.

So, at least when changing submodule URLs from the public URL to your own (read/write) clone URL, it seems that you can just edit the .gitmodules and .git/config files and have it work.