Using SSH key in a repo cloned using username and password

I have a repository cloned over https using my GitHub username and password. Is there a way for me to use a SSH key to do pulling and pushing in that repo without cloning it again over SSH? If so how?

You can update the remote URL like so:

git remote set-url origin SSH_URL

Theoretically you could also use a url.<base>.insteadOf setting to replace with in remote URLs. That might be more convenient if you have a lot of repositories.

1 Like