You need to tell Git to use SSH protocol instead of HTTPS. On the repository page on GitHub, select Clone or Download
and Use SSH
. You will get a URL for the SSH protocol in the form git@github.com:<user>/<repo>.git
.
Then run the following command in your working tree to tell Git to use this URL instead of the current one:
git remote set-url origin git@github.com:<user>/<repo>.git
This is also explained in the GitHub Help.
The method above won’t cause the repository to be cloned again, it just changes the communication protocol used for future synchronization between your local repo and GitHub.
Alternatively, you could set up a new remote using git remote add <new-remote-name> <url>
and then git pull <new-remote-name>
but Git would keep track of both protocols as separate remotes, so I do not recommend this.