Skip to content

Instantly share code, notes, and snippets.

@opyate
Last active March 10, 2020 10:35
Show Gist options
  • Save opyate/ee0679fe5eea8922a8753ada932d839d to your computer and use it in GitHub Desktop.
Save opyate/ee0679fe5eea8922a8753ada932d839d to your computer and use it in GitHub Desktop.
Change a git submodule remote

To change a git submodule's remote (in this case, from HTTPS to SSH):

SUB=my-submodule-name
$REMOTE=git@gitlab.com:path/to/remote.git

git submodule deinit $SUB
git rm $SUB
git commit -m "removed $SUB submodule at https remote"
rm -rf .git/modules/$SUB
git submodule add $REMOTE $SUB
git commit -m "added back $SUB submodule at ssh remote"
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment