ProgramGuru

Contribute through forks and upstream repositories

Contribute through forks and upstream repositories

In many open-source projects you cannot create branches directly in the main repository. A fork gives your account its own GitHub repository where you can push changes and propose them back.

What you’ll learn

  • Explain fork versus clone.
  • Configure origin and upstream.
  • Follow a contribution-oriented workflow.

Fork contribution topology

  1. Upstream

    Original project repository.

    source project
  2. Fork

    Your GitHub copy.

    origin
  3. Local branch

    Your focused contribution.

    push → PR to upstream
push → PR to upstream

A fork is a GitHub relationship between repositories

A fork is a GitHub-hosted copy relationship used for independent development and contributions. Your clone may use origin for your fork and another remote—commonly upstream—for the original project.

Before contributing, read CONTRIBUTING.md, code-of-conduct and test instructions. Keep each PR focused, sync with upstream when needed and avoid mixing unrelated personal changes.

Keep your fork's local main aligned with upstream

Run this in a disposable practice repository unless the lesson explicitly says otherwise.

git remote -v
git remote add upstream https://github.com/ORIGINAL_OWNER/REPO.git
git fetch upstream
git switch main
git merge --ff-only upstream/main

The exact sync strategy can vary. The key concept is that your fork and the original repository are separate remotes with separate branch states.

Practice: Forks and open source

Your task: Draw a four-node collaboration map: original GitHub repo, your fork, your local clone, and your feature branch. Label origin and upstream.

Common pitfall to avoid

Do not assume every project wants the same contribution style. Follow its documented branch, test, signing and PR requirements.

Check your understanding

In a common fork workflow, what does upstream usually refer to?
Choose one answer. You can try again.

Answer and explanation

The original repository you forked from.

Correct.

Forks and open source: what to remember

Contribute through forks and upstream repositories is complete when you can explain the state being changed before you run the command, not merely repeat the syntax.

Read further: official supporting documentation.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: Protect important branches with permissions and rules →