How to change a connection to GitHub from SSH to HTTPS?

here are some aliases (oneliners) to switch your repo from ssh to https and back. Assuming your default remote is named origin and your remote is github.com

alias git-https="git remote set-url origin https://github.com/$(git remote get-url origin | sed 's/https:\/\/github.com\///' | sed 's/[email protected]://')"
alias git-ssh="  git remote set-url origin [email protected]:$(    git remote get-url origin | sed 's/https:\/\/github.com\///' | sed 's/[email protected]://')"

they're a bit longer than necessary to make them idempotent


Assuming your remote is called origin, run

  • git remote set-url origin https://...
  • git remote set-url --push origin https://...

You can view the configured remotes with git remote -v, which should now show your updated URLs.

See the documentation for git-remote for more details.