Change from HTTPS to SSH in a Git Repo
The default way of cloning and maintaining Git repos for some might be using HTTPS. In case you want to switch to SSH, this is a very short guide on how to do that.
Change from HTTPS to SSH
There are basically 3 (or 4) steps to change from HTTPS to SSH.
Create your SSH key
To create your SSH key, use the following command:
ssh-keygen -t rsa -C "email@example.com"
-C flag stands for
comment and you can write whatever you want, I prefer to write my email.
Copy the key to your clipboard, as we need to upload it to our git remote repository (Github, Gitlab, Azure, or whatever provider you use).
Unless you specified a new location for the file, this is very it is located. Use the
cat command to print out the content and copy it manually.
Add key to remote host
You need to manually add the key to your remote git host. Every provider does this differently, but often it is accessible within the settings of the user.
Change to SSH
The final command to make the change work is to update your local repository to use SSH instead. You should replace this with the link to your specific repository.
git remote set-url origin firstname.lastname@example.org:USERNAME/REPOSITORY.git
git remote -v to check if everything has updated correctly.