What is a Git remote and what does origin mean?
Model answer
A remote is a named URL of another copy of the repository, usually on a host such as GitHub or GitLab. It lets you fetch teammates' commits and push yours.
origin is only the default name Git gives to the remote you cloned from. It has no special meaning: you can rename it, and a repository can have several remotes.
git remote -v
git remote add upstream https://github.com/org/project.git
git remote rename origin github
git remote set-url origin [email protected]:me/project.git
After you fetch, Git stores the remote's branches locally as remote-tracking branches such as origin/main. They are read-only bookmarks of where the remote was at the last fetch.
A common multi-remote setup is a fork: origin is your fork and upstream is the original project, so you can pull updates from upstream and push to origin.
Remember that a remote holds no magic; it is just another Git repository you talk to over HTTPS or SSH.
Key points
- A remote is a named URL to another repository copy
- origin is just the default name from clone
- Remote-tracking branches like origin/main are local bookmarks
- Forks commonly use origin plus upstream
Likely follow-ups
- How do you change a remote URL from HTTPS to SSH?
- What is the difference between origin/main and main?
Common mistakes
- Thinking origin is a special keyword
- Believing origin/main updates itself without a fetch