DEV Community

Nicky Marino
Nicky Marino

Posted on • Originally published at nickymarino.com on

How To Change a Git Repo's Authentication Protocol

This post was originally published on my website. Check it out for more awesome content!

HTTPS to SSH Key

Often I need to change a git repository to use an SSH key instead of my username and password to authenticate with the remote server. In order to do so, type the following in the repository’s folder on your machine:

$ git config remote.origin.url git@github.com:username/repository_name.git

Enter fullscreen mode Exit fullscreen mode

(Make sure to include the .git at the end of the repository name.)

SSH Key to HTTPS

In order to change it to do the reverse, type:

$ git config remote.origin.url https://github.com/username/repository

Enter fullscreen mode Exit fullscreen mode

Top comments (0)