Monday, March 23, 2015

Switching a git checked-out repo from SSL to SSH

Occasionally I'll clone a git repo (or a tool will do it for me) over SSL like this:
$ git clone
Cloning into 'gxui'...
remote: Counting objects: 906, done.
remote: Total 906 (delta 0), reused 0 (delta 0), pack-reused 905
Receiving objects: 100% (906/906), 477.53 KiB | 0 bytes/s, done.
Resolving deltas: 100% (548/548), done.
Checking connectivity... done.
$ cd gxui/
$ git remote -v
origin (fetch)
origin (push)
But later on I might want to push code, which is more convenient over SSH since I have a github key added. Switch the remote like this:
git remote set-url origin
$ git remote -v
origin (fetch)
origin (push)

No comments: