How to SSH a git repository after already cloned with https?

You should remove your HTTP remote (for example with origin):

git remote remove origin

and add the SSH remote instead

git remote add origin [email protected]:path/to/project.git

You will then also have to set the branch's remote again with

git push -u origin master

or

git branch --set-upstream-to=origin master

There is a pretty good documentation from GitHub:
https://help.github.com/en/articles/changing-a-remotes-url#switching-remote-urls-from-https-to-ssh

In short, this should do it:

git remote set-url origin [email protected]:PATH/REPOSITORY

Tags:

Git