How to change your git remote to/from SSH from/to HTTPS

in «tip» by Michael Beard
Tags: , , , , , ,

I recently needed to do this, so ...

Change your remote to SSH from HTTPS or reverse

This article has both Changing a remote's URL

Both are pretty much the same (orthogonal) and, in this instance, I need to switch from SSH and want HTTPS, I'll copy the steps for that.

Switching remote URLs from SSH to HTTPS
#### List your existing remotes to get name of the remote you want to change
git remote -v

origin  git@bitbucket.org:Legacy_Code/my_py_prj_templ.git (fetch)
origin  git@bitbucket.org:Legacy_Code/my_py_prj_templ.git (push)

#### ====================
#### now for the change
#### git remote set-url origin https://bitbucket.org/USERNAME/REPOSITORY.git
git remote set-url origin https://bitbucket.org/Legacy_Code/my_py_prj_templ.git

#### ====================
#### verify the remote URL has changed
git remote -v

origin  https://bitbucket.org/Legacy_Code/my_py_prj_templ.git (fetch)
origin  https://bitbucket.org/Legacy_Code/my_py_prj_templ.git (push)

If you need to do this for github or whatever, then just change the bitbucket.org to what you need. As long as it's git you should be ok.