Created
June 16, 2016 14:32
-
-
Save BinaryMuse/c45fe251a6951e909afc26c1f798d15f to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -e | |
origin="$1" | |
[ "$origin" == "" ] && echo "Please specify a remote to fix" && exit 1 | |
regex="github.com/(.*)/(.*)(.git)?" | |
current_url=$(git config remote."$origin".url) | |
if [[ $current_url =~ $regex ]] | |
then | |
owner="${BASH_REMATCH[1]}" | |
repo="${BASH_REMATCH[2]}" | |
new_url="[email protected]:$owner/$repo" | |
echo "Setting URL for $remote to $new_url" | |
git remote set-url "$origin" "$new_url" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment