Last active
April 6, 2020 19:19
-
-
Save jlowry/39aa652b496a40046578e43e9b2f0a1d to your computer and use it in GitHub Desktop.
Convert GitHub repo URLs from HTTPS to SSH
This file contains 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
#!/bin/bash | |
# Call it with directories to recursively change GitHub URLs found in .git/config and .gitmodules | |
# Usage: | |
# sh repo2ssh.sh <directory> [<directory> ...] | |
for f in "$@" | |
do | |
find "$f" \( -path '*/.git/config' -o -path '*/.gitmodules' \) \ | |
-type f -print0 | xargs -0 -t \ | |
sed -i '' 's,url = https://github\.com/,url = git@github.com:,g' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment