What is the difference between origin and upstream on GitHub?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In GitHub workflows, origin and upstream are just remote names, but they represent very different collaboration roles. Confusing them can lead to wrong-target pushes or stale pull requests. A clear remote strategy keeps contribution flow predictable, especially in fork-based projects.
Remote Names Are Aliases, Not Special Keywords
Git remotes are local aliases for repository URLs. The names are not reserved, but conventions matter.
Most teams use:
- '
originfor your writable fork or primary repo clone target.' - '
upstreamfor the canonical project repository.'
After cloning your fork, origin exists automatically.
Then add canonical source repository as upstream.
From then on, you fetch changes from upstream and push your branches to origin.
Why Fork Workflows Need Both
In open source and large internal platforms, contributors usually cannot push directly to canonical main branch. The two-remote model solves this:
- Develop and push safely to your fork.
- Pull latest canonical updates from upstream.
- Open pull requests from fork branch to upstream mainline.
This separation lowers risk and keeps maintainer branches protected.
Daily Sync Flow That Prevents Drift
A clean and repeatable sync routine is critical.
Then rebase feature work on updated main:
This produces cleaner pull requests and minimizes merge noise.
Inspect Tracking and Push Targets
Before pushing, inspect branch tracking so you do not accidentally update the wrong remote.
If a branch tracks wrong remote, fix it explicitly:
Use explicit pushes when multiple remotes are configured:
This is safer than plain git push in multi-remote repositories.
Handling Repository URL Changes
Organizations rename repos, move projects, or change protocol from HTTPS to SSH. Keep remotes updated.
Then verify:
Stale URLs are a common source of authentication and fetch confusion.
Multiple Remotes Beyond Two
Some teams add release mirrors or deployment remotes.
When you have many remotes, naming clarity is more important than tradition. Use names that express purpose and write access level.
Collaboration Policy That Scales
A simple policy avoids most mistakes:
originis always contributor writable remote.upstreamis always canonical remote.- Feature branches are pushed only to origin.
- Pull requests target upstream main branch.
- Local main is synced from upstream before rebasing feature branches.
Put this in contribution docs so onboarding is consistent.
Common Pitfalls
- Assuming
originalways points to canonical project. - Forgetting to fetch upstream before opening pull requests.
- Using plain
git pushand hitting unintended remote. - Force-pushing without lease protection on shared branches.
- Ignoring remote URL drift after repository migrations.
Summary
- '
originandupstreamare remote aliases with different collaboration roles.' - In fork workflows, push to origin and sync from upstream.
- Use explicit fetch and push commands to avoid wrong-target updates.
- Keep tracking branches and remote URLs audited.
- Standardized remote conventions reduce team-level Git errors.

