Git Clone vs Fork: Stop Mixing Them Up

Wait 5 sec.

Your first open source contribution starts with a question: do I clone this repo or fork it?Usually both. They do different jobs, and mixing them up is how people end up with broken remotes and pull requests that go nowhere.The one-sentence difference.Clone is a Git command. git clone copies a repository, with its full history, onto your machine.Fork is not a Git command. It’s a GitHub (or GitLab) feature that copies a repository into your own account on the server.Why fork at all?You can’t push to a repo you don’t have write access to. Cloning someone else’s project gets the code onto your laptop, but your push will be rejected. A fork gives you a copy you can push to. A pull request is how you ask the original maintainers to pull your changes in.Three places, three names. original repo ("upstream") │ click Fork on GitHub ▼ your fork ("origin") ◀──── git push ────┐ │ git clone │ ▼ │ your computer (local) ── commit on a branch ─┘ your fork ── Pull Request ──▶ original repoThe full workflow# 1. Fork on GitHub, then clone YOUR fork (check your username is in the URL)git clone https://github.com/YOUR-USERNAME/project.gitcd project# 2. Point a second remote at the originalgit remote add upstream https://github.com/original-owner/project.gitgit remote -v # origin = your fork, upstream = the original# 3. Work on a branch, never directly on maingit checkout -b fix-typo-in-readmegit add .git commit -m "Fix typo in README"# 4. Push to YOUR fork, then open a pull request on GitHubgit push origin fix-typo-in-readmeShortcut: with the GitHub CLI, gh repo fork owner/project --clone does the fork, the clone, and sets origin and upstream for you.Forks don’t update themselves.Once you fork, your copy is frozen at that moment. If the original moves on, you have to sync it, and there are three ways:Click Sync fork on your fork’s page on GitHub.Run gh repo sync YOUR-USERNAME/project -b main.Use plain Git:git fetch upstreamgit checkout maingit merge upstream/maingit push origin mainSync before you start new work so your pull request doesn’t conflict with changes you didn’t know about.Which one do you need?SituationUseYour own repo, or a team repo where you have write accessCloneContributing to a project you can’t push toFork, then clone your forkJust reading or running someone’s code locallyCloneTaking a project in your own directionForkForks are bigger than pull requests.Forking is also how communities protect themselves. When Terraform’s license changed in 2023, the community forked its last open version into OpenTofu. When Redis changed licenses in 2024, the Linux Foundation backed Valkey. Both forks now have their own governance and keep their open licenses.That connects to last week. A fork carries the original’s license with it. Your fork of an MIT project is still bound by the MIT notice, and a fork of a GPL project must stay GPL if you distribute it.Common MistakesCloning the original instead of your fork. Check the username in the URL.Committing straight to main on your fork. Branch for every change.Forgetting upstream. Without it you can’t sync.Assuming the fork updates automatically. It doesn’t.Further reading: GitHub Docs: “Fork a repo” and “Syncing a fork.”