Skip to content

Instantly share code, notes, and snippets.

@jlowry
Last active April 6, 2020 19:19
Show Gist options
  • Save jlowry/39aa652b496a40046578e43e9b2f0a1d to your computer and use it in GitHub Desktop.
Save jlowry/39aa652b496a40046578e43e9b2f0a1d to your computer and use it in GitHub Desktop.
Convert GitHub repo URLs from HTTPS to SSH
#!/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