Skip to content

Instantly share code, notes, and snippets.

@bobzoller
Last active June 15, 2017 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobzoller/1edf23586cf274192b2a8137ab1c1ff8 to your computer and use it in GitHub Desktop.
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
#!/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 "git@github.com:$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