I add a submodule from a git@… URL, to be able to develop in it. Now I want to deploy the app and replace the URL with an git://… one, so it doesn’t need authentication to the submodule’s repo from Capistrano. Is editing the URL in .gitmodules totally enough to accomplish this?
Share
Editing the
.gitmodulesfile (then committing, and pushing it) will be adequate for any new clones.Additionally, when a submodule is initialized (e.g.
git submodule init …,git submodule update --init …, orgit clone --recursive …, etc.) its URL is copied from the.gitmodulesfile to the repository’s.git/configfile.So, if you have any existing “deployment clones” (the ones you now want to access the submodules through
git://…URLs), you will also have to update the URL in their.git/config. You can usegit submodule syncto automatically copy the submodule URLs from the current.gitmodulesfile to your.git/configfile (i.e. once you have pulled the commit that updates the.gitmodulesfile).The submodule URLs in
.git/configare not normally automatically updated because there are cases where you only want to override the URL in certain situations. Specifically, you will often want to usegit@…URLs in your repository’s.git/config(so you can push over SSH), but putgit://…URLs in.gitmodules(so that the general public does not need to do SSH-based authentication).