Created
August 12, 2024 07:02
-
-
Save filipeandre/7fe7f3feb9709102a69f93ff5305018e to your computer and use it in GitHub Desktop.
Migrate gitmodules from https to ssh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| git config -f .gitmodules --get-regexp 'submodule\..*\.path' | while read -r key submodule_path; do | |
| http_url=$(git config --file .gitmodules --get submodule.$submodule_path.url) | |
| ssh_url=${http_url/https:\/\/github.com\//[email protected]:} | |
| git config -f .gitmodules submodule.$submodule_path.url $ssh_url | |
| git config -f .gitmodules submodule.$submodule_path.shallow true | |
| echo "Updated $submodule_name ($submodule_path) URL:" | |
| echo " From: $http_url" | |
| echo " To: $ssh_url" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment