Fork & Sync

Clone or fork? The decision

A fork is your own copy of someone else's repository, living under your GitHub account. You need one whenever you want to change a project you can't push to directly — which is almost every open-source project. Deciding is simple:

  • Your repo, or you have write access (a team project you're a member of) → just git clone it and work on a branch.
  • Someone else's project → fork it first, then clone your fork. You push freely to your copy, and later offer the changes back.

Mental model: a fork is your photocopy on GitHub; a clone is the copy on your desk. Forking copies the project to your account, cloning downloads it to your machine — to contribute to someone else's project you do both, in that order.

Fork it and get it on your machine

Forking happens on GitHub, not in Git itself — there's no git fork command. Click the button on the project's page, or let the GitHub CLI (gh) do the click and the clone in one go:

Fork a project, then clone your copy

Terminal
$ gh repo fork original/project --clone
$ # or: click Fork on github.com, then clone YOUR copy:
$ git clone https://github.com/you/project.git
In VS Code
  1. On github.com, open the project and click Fork (top-right)
  2. Back in VS Code, open the Command Palette (Ctrl+Shift+P)
  3. Type Git: Clone and paste your fork's URL — the one with your username in it

Common slip: cloning the original instead of your fork. If the URL doesn't contain your username, you won't be able to push.

origin vs upstream

Your clone now knows one remote: origin, pointing at your fork. But the original project keeps moving without you. By convention you add it as a second remote called upstream, so you can pull its new commits into your copy:

Keep a fork in sync with the original

Terminal
$ git remote add upstream https://github.com/original/project.git
$ git fetch upstream
$ git merge upstream/main
In VS Code
  1. Add the upstream remote via Source Control → '…' → RemoteAdd Remote…
  2. Then '…' → Pull, PushFetch, and merge upstream/main into your main

You only add the remote once. After that, syncing is just fetch + merge whenever your fork feels stale.

So: origin = your fork (you push here), upstream = the original (you fetch from here). Two nicknames, two directions.

The one-click sync

GitHub can do the upstream merge for you. On your fork's page, just under the branch picker, there's a Sync fork button — click it, then Update branch, and GitHub copies the original's new commits into your fork. Then bring them down to your machine:

Pull the freshly synced commits down

Terminal
$ git pull
In VS Code
  1. Click Sync Changes (the circular arrows) in the status bar
  2. Or Source Control → '…' → Pull

Sync fork updates your copy on GitHub; git pull updates the copy on your desk. You need both.

A pull request from a fork

Here's the payoff. Make your change on a branch and push it — to origin, your fork. GitHub notices the new branch and offers to open a pull request back to the original project, even though you can't push there. That's how open source works: anyone can fork, change, and propose.

Push a branch to your fork, then propose it

Terminal
$ git switch -c fix-typo
$ git commit -am "Fix typo in README"
$ git push -u origin fix-typo
In VS Code
  1. Push the branch, then open your fork on github.com
  2. GitHub shows a Compare & pull request banner — click it
  3. Check the target: it defaults to the original repo's main. Click Create pull request

The maintainers review it on their repo, and if they merge it, your change lands in the real project.

Reviews, follow-up commits and merging work exactly like any other PR — the Pull Requests chapter covers that whole conversation.

Tip: keep your fork's main untouched and do every change on a branch. A clean main is easy to sync with upstream; one you've committed to directly will fight you with conflicts.

Up next: marking versions of your project — Tags & Releases.

FAQ

Frequently Asked Questions

What is the difference between a fork and a branch?
A branch is another line of work inside the same repository. A fork is your own copy of someone else's repository on GitHub, used to contribute when you don't have write access — see Branches for how branches work.
How do I keep my fork up to date?
Add the original repo as a remote called upstream, then git fetch upstream and merge upstream/main into your own main. Or click Sync fork on your fork's GitHub page and run git pull locally.
Do forks update automatically when the original changes?
No — a fork is a snapshot from the moment you created it. New commits in the original only arrive when you sync, either with GitHub's Sync fork button or by merging upstream/main yourself.
Can the original project's owners see my fork?
Yes — a fork of a public repository is public, and GitHub lists it under the original's Forks count. Anything you push to a public fork is visible to everyone, so keep secrets out of it.