Created
January 4, 2019 04:35
-
-
Save oscarmorrison/01bcc312d91315d0af281c9e3d0f8c37 to your computer and use it in GitHub Desktop.
Revisions
-
oscarmorrison created this gist
Jan 4, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ echo "Opening git repo" giturl=$(git config --get remote.origin.url) giturl=$( tr '[A-Z]' '[a-z]' <<< $giturl) if [[ $giturl == *"https"* ]] then echo "Switching repo remote origin url from HTTPS to SSH" echo $giturl giturl=${giturl#https://github.com/} repo=${giturl/\.git} repo="[email protected]:$repo.git" git remote set-url origin $repo git remote -v else echo "Switching repo remote origin url from SSH to HTTPS" echo $giturl giturl=${giturl#git@github.com:} repo=${giturl/\.git} repo="https://github.com/$repo.git" git remote set-url origin $repo git remote -v fi