Skip to content

Instantly share code, notes, and snippets.

@BinaryMuse
Created June 16, 2016 14:32
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 BinaryMuse/c45fe251a6951e909afc26c1f798d15f to your computer and use it in GitHub Desktop.
Save BinaryMuse/c45fe251a6951e909afc26c1f798d15f to your computer and use it in GitHub Desktop.
#!/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="git@github.com:$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