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

dickbarba picture dickbarba · Jun 6, 2015 · Viewed 19.8k times · Source

I created my first repository in GitHub yesterday. When making the connection I used SSH instead of HTTPS, so I went through a little painful SSH key creation and connection process. At some point I got stuck and the connection failed. I wondered at that moment how I could revert the process I started and begin with a HTTPS connection instead. Happily, today I got the connection working through SSH but I'm wondering about the value of being able to change the type of connection (SSH vs HTTPS) and if there is a way to do it.

Answer

Chris picture Chris · Jun 6, 2015

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.