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="git@github.com:$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