GitHub Set Remote

Connect your local Git repository to a GitHub repository using git remote. Understand origin and remote URLs.

On this page

What is a remote?

A remote is a version of your repository hosted elsewhere, typically on GitHub.

Add a remote

git remote add origin git@github.com:username/repository.git

Verify remote

git remote -v

Push to remote

git push -u origin main

Change remote URL

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

Remove remote

git remote remove origin

Common mistake

Using HTTPS remote while expecting SSH authentication.