Skip to content

Instantly share code, notes, and snippets.

@nightsparc
Forked from opyate/change_git_submodule.md
Created February 28, 2019 12:02
Show Gist options
  • Save nightsparc/440d48c06c167d0667daa806969150d4 to your computer and use it in GitHub Desktop.
Save nightsparc/440d48c06c167d0667daa806969150d4 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