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 cloneit 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
$ gh repo fork original/project --clone
$ # or: click Fork on github.com, then clone YOUR copy:
$ git clone https://github.com/you/project.git - On github.com, open the project and click Fork (top-right)
- Back in VS Code, open the Command Palette (
Ctrl+Shift+P) - 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
$ git remote add upstream https://github.com/original/project.git
$ git fetch upstream
$ git merge upstream/main - Add the upstream remote via Source Control → '…' → Remote → Add Remote…
- Then '…' → Pull, Push → Fetch, and merge
upstream/maininto 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
$ git pull - Click Sync Changes (the circular arrows) in the status bar
- 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
$ git switch -c fix-typo
$ git commit -am "Fix typo in README"
$ git push -u origin fix-typo - Push the branch, then open your fork on github.com
- GitHub shows a Compare & pull request banner — click it
- 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.