Skip to content

Instantly share code, notes, and snippets.

@neikeq
Created June 16, 2020 02:19
Show Gist options
  • Save neikeq/6228b65530896320c8df0fc6f0e4d114 to your computer and use it in GitHub Desktop.
Save neikeq/6228b65530896320c8df0fc6f0e4d114 to your computer and use it in GitHub Desktop.
Scripts to automatically convert URL of all git remotes from HTTPS to SSH and viceversa
#!/bin/bash
git remote | while read -r REMOTE ; do
echo "Converting remote '$REMOTE' to HTTPS"
git remote set-url $REMOTE $(git remote show $REMOTE | grep "Fetch URL" | sed 's/ *Fetch URL: //' | sed 's/[email protected]:/https:\/\/github.com\//')
done
#!/bin/bash
git remote | while read -r REMOTE ; do
echo "Converting remote '$REMOTE' to SSH"
git remote set-url $REMOTE $(git remote show $REMOTE | grep "Fetch URL" | sed 's/ *Fetch URL: //' | sed 's/https:\/\/github.com\//[email protected]:/')
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment