Last active
June 15, 2017 21:22
-
-
Save bobzoller/1edf23586cf274192b2a8137ab1c1ff8 to your computer and use it in GitHub Desktop.
find all the Github repos in a local directory (recursive) and repoint them 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 | |
while read -r dir; do | |
echo "$dir" | |
cd "$(dirname "$dir")" || exit 1 | |
origin=$(git remote get-url origin 2>/dev/null) | |
if echo "$origin" | grep -q '^https://github.com/'; then | |
repo=$(echo "$origin" | sed 's#^https://github.com/##') | |
echo "fixing $dir $repo" | |
git remote set-url origin "[email protected]:$repo" | |
fi | |
done < <(find "$PWD" -type d -name '.git') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment