A fork is your own complete copy of someone elses repository, hosted under your account on a platform like GitHub or GitLab. It lets you change a project however you like without needing permission, and then propose those changes back to the original through a pull request. Forking is not a built-in Git command; it is a feature these hosting platforms add on top of Git. It is the mechanism that makes large open-source collaboration possible between strangers.
What forking really does
When you fork a project, the platform creates a separate repository on your account that starts identical to the original. The original is usually called the upstream repository. From that point your fork is yours: you can push commits, create branches, and experiment freely, and none of it touches the upstream project. The two repositories are linked in the platform interface so you can later send changes back, but they are otherwise independent.
This is different from cloning. Cloning copies a repository to your local machine. Forking copies it to your account on the server. In practice you usually fork on the platform and then clone your fork to your computer to work on it. If the platform side is new to you, see how to use Git and GitHub.
Fork versus branch
These get confused constantly, so here is the clear distinction.
| Aspect |
Branch |
Fork |
| Lives |
Inside one repository |
As a separate repository you own |
| Created by |
A core Git command |
A platform feature on top of Git |
| Permission needed |
Write access to the repo |
None, anyone can fork a public repo |
| Typical use |
Your own or your teams work |
Contributing to a project you do not own |
| Send changes back |
Merge into another branch |
Open a pull request to the upstream |
The rule of thumb: branch when you can write to the repository, fork when you cannot.
How a fork-based contribution works
// after forking on the platform, clone your fork locally
git clone https://github.com/you/project.git
git switch -c fix-typo // make a branch for the change
git commit -am "fix typo in docs"
git push origin fix-typo // push to your fork
// then open a pull request from your fork to the upstream repo
The upstream maintainers review the pull request and merge it if they accept it. Your fork stays around, and you can keep it in sync by pulling updates from upstream.
How to use forks well
- Fork only when you do not have write access; otherwise just branch in the original repo.
- Add the original as an
upstream remote so you can pull its latest changes into your fork.
- Sync your fork before starting new work so your changes apply cleanly.
- Open one focused pull request per change rather than bundling unrelated edits.
- Delete your fork once the work is merged and you no longer need it.
What to skip
- Skip forking when you can branch. Maintaining a divergent copy is extra overhead if you already have write access.
- Skip letting a fork go stale. A fork that never syncs drifts far from upstream and becomes hard to contribute from.
- Skip giant pull requests. Maintainers review smaller, focused changes much faster.
- Skip assuming a fork is private. Forking a public repo creates another public repo by default on most platforms.
FAQ
Is forking the same as cloning?
No. Forking makes a copy on your account on the hosting platform. Cloning makes a copy on your local machine. You often fork first, then clone your fork to work on it.
Is a fork part of Git itself?
Not really. Git has no fork command. Forking is a feature added by platforms like GitHub and GitLab to make it easy to copy and contribute to projects you do not control.
How do I get updates from the original project?
Add the original repository as a remote, usually named upstream, then fetch and merge its changes into your fork. This keeps your copy current with the source project.
Do I need a fork to contribute to open source?
Usually yes, if you lack write access to the project. The standard flow is to fork, make your change on a branch, push it to your fork, and open a pull request to the original.
Where to go next
Learn what a Git repository is, understand branches inside a repo, and compare Git and GitHub.