GitHub Set Remote
GitHub Set Remote: Connecting Local Repos to Remote URLs
A Git remote is a named bookmark that stores the web or SSH address of a hosted repository on GitHub, GitLab, or another server. By convention, your primary remote repository is named origin.
Adding the origin Remote
When you initialize a project locally with git init, it has no remotes configured yet. Link it to an empty GitHub repository using git remote add:
git remote add origin git@github.com:your-username/starter-site.git
Verify the bookmark was saved and inspect separate fetch and push URLs:
git remote -v
You should see two lines for origin: one labeled (fetch) and one labeled (push).
Changing or Renaming an Existing Remote
If you cloned a repository using HTTPS and later set up SSH keys, update the remote URL in place with git remote set-url instead of re-cloning:
git remote set-url origin git@github.com:your-username/starter-site.git
You can also rename or remove a remote bookmark anytime:
git remote rename origin upstream
git remote remove upstream
Managing Multiple Remotes (origin and upstream)
Open-source contributors frequently attach two remotes to the same local folder: origin pointing to their personal fork and upstream pointing to the original project repository. Adding a second remote takes one command:
git remote add upstream git@github.com:org-name/starter-site.git
Common Remote Setup Mistakes
Running git remote add origin ... a second time fails with error: remote origin already exists. Whenever you want to replace an existing URL, use git remote set-url origin <new-url>.
Another common error is pasting the browser page URL without .git or using a typo in the repository slug, which triggers Repository not found on push. Copy the clone URL directly from the green Code button on GitHub.
Frequently Asked Questions
Does git remote add upload my files automatically?
No. Adding a remote only saves the repository address in .git/config. You still need to run git push -u origin main to upload commits.
Where does Git store remote URLs on my machine?
Git saves remote definitions inside .git/config within your project directory. You can inspect them safely with git remote -v.
Can a remote have a name other than origin?
Yes. origin is simply the default name git clone uses. Teams often add remotes named upstream, staging, or production.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With