Created
July 23, 2020 17:58
-
-
Save cacharle/01b70563215306d6b6b16e8d5ebdb8cc to your computer and use it in GitHub Desktop.
Change github.com remote to use ssh
This file contains 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/sh | |
[ $# -eq 0 ] && echo "Usage $0 REPOSITORY ..." && exit 1 | |
for repo in $@; do | |
if [ ! -d $repo ] || [ ! -d $repo/.git ]; then | |
echo "$repo: Is not a repository" | |
continue | |
fi | |
cd $repo | |
origin_url=`git remote get-url origin` | |
if [ $? -ne 0 ]; then | |
echo "$repo: No remote named origin" | |
cd .. | |
continue | |
fi | |
url=`echo $origin_url | sed 's_.*/\(.*\)[email protected]:cacharle/\1.git_'` | |
echo "$repo: Changing remote url to: $url" | |
git remote set-url origin $url | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment