Skip to content

Fork

In one line

A fork is a server-side copy of a repository under your own account, linked to the original for pull requests.

In simple words

A fork is a complete copy of a repository made on the server (GitHub, GitLab). It lives under your account and maintains a link to the original repository (called "upstream"). Forking is the standard way to contribute to a project you do not have write access to.

The workflow: fork the original repo on GitHub, clone your fork locally, create a feature branch, make changes, push to your fork, then open a pull request from your fork to the original (upstream) repository.

Forks are different from clones: a fork is server-side and preserves the upstream link; a clone is a local copy. You typically clone your fork (not the original) so you can push changes. To stay in sync with the original, you add it as a remote called upstream and fetch from it periodically.

Example

bash
# After forking on GitHub, clone YOUR fork
git clone https://github.com/you/project.git
cd project

# Add the original as 'upstream' to stay in sync
git remote add upstream https://github.com/original/project.git
git fetch upstream

Fork on GitHub, clone your fork, add upstream remote for syncing.

Common confusions

  • Confused with: clone

    The difference: A fork is a server-side copy under your account with an upstream link; a clone is a local copy on your machine. You fork to contribute, clone to work locally.

  • Confused with: branch

    The difference: A fork copies the entire repository to a new account; a branch is a line of development within the same repository. Forks are for cross-account contribution; branches are for internal development.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary