Home Career and Growth Understanding the Terms Upstream vs Origin Used with GitHub

Understanding the Terms Upstream vs Origin Used with GitHub

267
0

When we start working with GitHub, especially with forks and pull requests, we quickly come across two important terms:

  • origin
  • upstream

These words appear in commands, tutorials, and GitHub workflows — but Git itself doesn’t explain what they mean. Understanding them clearly will make our Git and GitHub experience far easier.

In this post, we’ll break down these terms in the simplest way possible, using real examples and diagrams we can visualize.


1. What Is a Remote in Git? (Quick Foundation)

Before we understand origin and upstream, we need to know one thing: A remote is a link to a repository stored somewhere else (usually on GitHub).

When we clone a project, Git automatically creates a remote reference for us.

We can see our remotes using:

git remote -v

2. What Is “origin”? (Our Fork or Main Remote)

origin is the default name Git gives to the remote we cloned from.

Examples:

If we clone our own repository:

  • origin = our GitHub repo

If we fork someone else’s repository and clone our fork:

  • origin = our fork
  • origin/main = the main branch of our fork

In simple terms:

origin is “our copy of the repo on GitHub.”

This is where we normally push our work.


3. What Is “upstream”? (The Original Repository We Forked From)

When we fork a repository, we create a copy under our GitHub account.

But the original repository still exists — and it keeps receiving updates.

We add a remote pointing to that original repository and call it:

upstream

Example:

git remote add upstream https://github.com/original-owner/project.git

Now we have:

  • origin → our fork
  • upstream → the original project

We use upstream to pull updates from the original repo so our fork stays current.

In simple terms:

upstream is “the source project we forked from.”


4. Why Do These Terms Matter?

Because GitHub contributions follow this flow:

upstream (original repo) → origin (our fork) → our local machine

And when we send changes:

our local branch → origin branch → pull request → upstream

This relationship is essential for:

  • contributing to open-source
  • working with forks
  • keeping our fork updated
  • avoiding merge conflicts
  • submitting clean pull requests

Once we understand origin and upstream, the entire GitHub workflow makes sense.


5. Simple Real-World Example

Imagine we want to contribute to a public project called cool-app.

Step 1: We fork it

A copy appears in our GitHub account.

Step 2: We clone our fork

git clone https://github.com/our-username/cool-app.git

Now:

  • origin = our fork

Step 3: We add the original repo as upstream

git remote add upstream https://github.com/original-owner/cool-app.git

Now:

  • upstream = original repo*

Step 4: Keep our fork updated

git fetch upstream
git merge upstream/main

Now our fork is synced with the real project.


6. Comparing “origin” vs “upstream”

Here’s the simplest way to remember:

Conceptoriginupstream
Belongs toUsOriginal project
Used forPushing our changesPulling latest updates
Created whenWe cloneWe add it manually
Typical URLour-username/repooriginal-owner/repo
RoleOur working copySource of truth

⚡ Quick memory trick

origin = us
upstream = them

That’s it!


7. Does Git Require These Names?

No.

These are conventions, not rules.

We could name them:

  • myfork instead of origin
  • mainrepo instead of upstream

But almost every GitHub tutorial, open-source repository, and DevOps team uses origin and upstream, so it’s best to follow the standard.


9. Other Related Git & GitHub Terms You Will See

When working with origin and upstream, several other Git and GitHub terms often appear in pull requests, branch workflows, and remote setup. Here is a clear explanation of each one.


a. Remote

A named link to a repository stored somewhere else (usually on GitHub).

Examples:

  • origin
  • upstream

b. Head (HEAD)

The branch or commit we are currently working on.

In Pull Requests:

  • head branch = branch containing our new changes.

c. Base

The branch we want to merge changes into.

In PRs:

  • base branch = the target branch (often main).

So PRs always compare:

head → base

d. Tracking Branch

A local branch linked to a remote branch so Git knows where to pull from or push to.

Example:

dev (local) ↔ origin/dev (remote)

e. Remote-Tracking Branch

Git’s record of the branch on the remote.

Examples:

  • origin/main
  • upstream/main

These are not actual branches—just references.


f. Downstream

The repo or branch that receives changes.

Examples:

  • Our fork is downstream of the original project.
  • Contributors are downstream from maintainers.

g. Fork vs Clone

  • Fork → copy on GitHub
  • Clone → copy on our local machine

Fork is for collaboration, clone is for development.


h. Upstream Branch (Git Concept — Different from GitHub’s Upstream Remote)

This is where most beginners get confused.

In Git (not GitHub):

An upstream branch is the remote branch that our local branch is tracking.

Example:
If our local main tracks origin/main, then:

  • Upstream branch = origin/main

This is what Git refers to when it prints:

Your branch is ahead of its upstream branch by 2 commits.

Important:

This has nothing to do with GitHub’s “upstream” remote.

  • GitHub upstream remote → the original project we forked
  • Git upstream branch → the remote branch our local branch tracks

Two completely different ideas that share the same word.


10. Quick Reference Table

TermMeaningExample
originOur GitHub repo (fork or main)origin/main
upstream (GitHub)Original repo we forked fromupstream/main
remoteA named link to a repoorigin, upstream
HEADBranch we’re onHEAD → main
head branch (PR)Branch with new changesfeature/login
base branch (PR)Branch receiving changesmain
tracking branchLocal branch linked to remotedev ↔ origin/dev
remote-tracking branchGit’s record of remote branchorigin/main
upstream branch (Git)Remote branch our local branch tracksorigin/main
downstreamRepo receiving updatesour fork
forkCopy of repo on GitHubuser/project
cloneLocal working copyon our machine

9. Summary

  • origin is our fork or the repository we cloned
  • upstream is the original repository we forked from
  • We push to origin
  • We pull updates from upstream
  • This setup is essential for open-source and team collaboration

Once we understand these two terms, working with GitHub becomes much easier — especially when dealing with forks and pull requests.

Previous articleForking a GitHub Repository and When We Should Use It
Next articleUnderstanding Pull Requests (PRs) in GitHub
Heartin Kanikathottu
As a seasoned Cloud and Security Architect, I’ve led transformative initiatives in key roles, including Vice President at Morgan Stanley, Principal Architect at Societe Generale, and Tech Lead & Cloud Security Architect at VMware, among others. I’m also an internationally published author with multiple books available on platforms like Amazon and O'Reilly. Notably, one of my books was recognized as the 8th best cloud computing book of all time in 2020, reflecting the impact of my contributions to the field. With over 15 professional certifications from providers such as Microsoft (Azure), Amazon (AWS), Oracle (Java), Pivotal (Spring), and IBM, I bring a wealth of expertise to my work. Academically, I hold dual Master’s degrees in Cloud Computing and Data Analytics. I’m passionate about sharing knowledge and mentoring others, which is why I actively speak at global technical forums such as Tech Opportunities Fest at Platform Calgary, Google's Kubernetes Meetup, Java User Group, Elasticsearch Meetup, and the Agile India Conference.

LEAVE A REPLY

Please enter your comment!
Please enter your name here