What is the difference between origin and upstream on GitHub?


What is the difference between origin and upstream on GitHub?

When a git branch -a command is done, some branches have a prefix of origin (remotes/origin/..) while others have a prefix of upstream (remotes/upstream/..).

This question is tagged with git github git-branch

~ Asked on 2012-02-13 08:35:10

The Best Answer is


This should be understood in the context of GitHub forks (where you fork a GitHub repo on GitHub before cloning that fork locally).

From the GitHub page:

When a repo is cloned, it has a default remote called origin that points to your fork on GitHub, not the original repo it was forked from.
To keep track of the original repo, you need to add another remote named upstream

git remote add upstream git://github.com/<aUser>/<aRepo.git>

(with aUser/aRepo the reference for the original creator and repository, that you have forked)

You will use upstream to fetch from the original repo (in order to keep your local copy in sync with the project you want to contribute to).

git fetch upstream

(git fetch alone would fetch from origin by default, which is not what is needed here)

You will use origin to pull and push since you can contribute to your own repository.

git pull
git push

(again, without parameters, 'origin' is used by default)

You will contribute back to the upstream repo by making a pull request.

fork and upstream

~ Answered on 2012-02-13 09:10:56


In a nutshell answer.

  • origin: the fork
  • upstream: the forked

~ Answered on 2020-12-13 03:34:56

Most Viewed Questions: