Menu
×
   ❮     
     ❯   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

Git Set Remote from GitHub


Set GitHub Remote Origin

Now that your SSH key is added to GitHub, you can securely connect your local repository to GitHub using SSH.

Test Your SSH Connection

First, test that your SSH connection to GitHub works:

Example

ssh -T git@github.com
The authenticity of host 'github.com (140.82.121.3)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,140.82.121.3' (RSA) to the list of known hosts.
Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.

If the last line contains your username on GitHub, you are successfully authenticated!


Get Your Repository's SSH Address

On GitHub, go to your repository and click the Code button. Make sure SSH is selected, then copy the SSH URL (it starts with git@github.com:):

GitHub Get SSH Code


Add or Update the Remote Origin

To add the remote origin (first time):

Example

git remote add origin git@github.com:your-username/your-repo.git

To update an existing remote to use SSH:

Example

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

Congratulations! You are now ready to use GitHub with SSH.


Exercise?What is this?
Test your skills by answering a few questions about the topics of this page

Drag and drop the correct subcommand to add a new remote.
git remote origin git@github.com:username/repo.git
set-url
add
update
push




×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.