Forks & Keeping in Sync

Fork Workflow (open source)

When you don't have write access to a repo (e.g. contributing to open source), you fork it - your own server-side copy - then PR back.

upstream (original)  ──fork──▶  origin (your fork)  ──clone──▶  your laptop
        ▲                                                          │
        └────────────────── Pull Request ◀───────────────────────┘

You add the original as a second remote called upstream and sync from it:

$ git remote add upstream https://github.com/original/project.git
$ git fetch upstream
$ git switch main && git merge upstream/main   # or: git rebase upstream/main
$ git push origin main                          # update your fork
Tip: origin = your fork (you push here). upstream = the original (you pull updates from here). Keep your fork's main in sync with upstream/main before starting new work to avoid painful conflicts later.