Skip to content

Instantly share code, notes, and snippets.

@ten0s
Created May 20, 2014 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ten0s/12890cc4a398de8bfbb8 to your computer and use it in GitHub Desktop.
Save ten0s/12890cc4a398de8bfbb8 to your computer and use it in GitHub Desktop.
Replace github's https url with ssh
function git-sshurl() {
local OldUrl=`git remote -v | sed -E -n 's/origin\s*(.*) \(push\)/\1/p'`
local NewUrl=`echo $OldUrl | sed -E 's#https://(.*)/(.*)/(.*)#git@\1:\2/\3#'`
echo "old url:" $OldUrl
echo "new url:" $NewUrl
git remote set-url origin $NewUrl
}
@cyberbikepunk
Copy link

nice one thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment