THE GITHTML FIELD GUIDE

Understand origin and upstream in a fork workflow

Origin and upstream are names assigned to remote repositories; Git does not give those names universal ownership rules. In a common fork setup, origin points to your fork and upstream points to the original project. A branch’s upstream is a separate tracking relationship, so always inspect URLs and branch configuration before fetching or pushing.

Do not infer ownership from a familiar name

Cloning usually creates a remote called origin for the URL you cloned. If you cloned the original project, origin points there, not to a fork you later created. A remote named upstream exists only when someone configures it. Both names are local aliases and can be changed, so the URL is the authoritative clue to the destination.

The word upstream also appears in branch tracking. A local feature branch might track origin/feature, even though a separate remote named upstream points to the main project. Confusing these meanings can lead to pushing toward the wrong owner or pulling a different branch than intended. Read the full relationship rather than relying on the word alone.

Draw a small remote inventory

Inspect fetch and push URLs because a remote can have different destinations for each. The commands below are read-only. Replace the remote name only after listing the configured names. If a URL contains embedded credentials, do not copy it into a ticket; rotate exposed credentials and use a supported credential mechanism instead.

  1. Write down which repository accepts your contributions and which repository supplies the project’s authoritative changes. They may be the same repository.
  2. Check the current branch’s upstream separately from the remote inventory so a convenient default does not silently select the wrong branch.
shell
git remote -v
git remote get-url origin
git remote get-url --push origin
git branch -vv

Use explicit destinations until the setup is clear

In a fork workflow, you might fetch from the original project, update a local branch, and push your contribution branch to your fork. Opening a pull request then proposes that branch to the original project. These are separate operations with separate permissions. Read access to the original does not imply write access, and having a fork does not change an existing clone’s remote automatically.

Before changing any remote URL, confirm that the current alias is not serving another intentional purpose. Adding a second clearly named remote can be better than replacing a known destination, but only when you actually need it. Finish by verifying the URLs and tracking relationship again. A precise inventory is more dependable than assuming that every tutorial’s origin/upstream diagram matches your checkout.

Remote names are private to the clone. Your teammate can use different aliases for the same repositories without changing the shared commits or the hosting service’s ownership.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All git fundamentals guides →

Read as MarkdownAll guides

Understand origin and upstream in a fork workflow · gitHtml