Last active
November 19, 2017 16:27
-
-
Save scribu/4548059 to your computer and use it in GitHub Desktop.
Fixes the annoying "You can't push to X. Use Y" git error.
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 | |
# Fixes the annoying "You can't push to X. Use Y" git error. | |
while read -r line | |
do | |
read -a array <<< "$line" | |
remote="${array[0]}" | |
url="${array[1]}" | |
new_url=${url/git:\/\/github\.com\//[email protected]:} | |
if [ "$url" != "$new_url" ] | |
then | |
git remote set-url --push $remote $new_url | |
echo "Fixed url for '$remote' remote." | |
fi | |
done < <(git remote -v | grep '(push)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment