Skip to content
Author: ytianle

Setup Origin⚓︎

This guide helps you change your Git remote origin from HTTPS to SSH.

Check Current Remote URL⚓︎

The command below shows your current remote URL:

terminal
git remote -v

The output can be:

terminal
>>> origin  https://github.com/<your-username>/your-repo.git (fetch)
>>> origin  https://github.com/<your-username>/your-repo.git (push)

Get GitHub SSH URL⚓︎

On GitHub, navigate to your repository page. Click on the green "Code" button, then select "SSH" to copy the SSH URL:

terminal
git@github.com:<your-username>/your-repo.git

Set origin to SSH⚓︎

Now, set the remote URL to the SSH URL you copied:

terminal
git remote set-url origin git@github.com:<your-username>/your-repo.git

Confirm the Change⚓︎

Check the remote URL again:

terminal
git remote -v

The output should now be:

terminal
origin  git@github.com:<your-username>/your-repo.git (fetch)
origin  git@github.com:<your-username>/your-repo.git (push)

Test SSH Connection⚓︎

terminal
ssh -T git@github.com

If successful, you should see:

Hi <your-username>! You've successfully authenticated, but GitHub does not provide shell access.