Git cloning vs forking

Greg Foster
Greg Foster
Graphite software engineer

This guide looks at the nuances of git fork and git clone, providing clear examples to illustrate their differences and applications.

The git clone command is used to create a local copy of a remote repository. This command duplicates the repository, including all its files, history, and branches, onto your local machine. Cloning is the first step most developers take when they want to work on an existing project or start a new one based on another project.

To clone a repository, you would use the following command in your terminal:

Terminal
git clone <repository-url>

For example:

Terminal
git clone https://github.com/username/project.git

This command creates a directory named project in your current directory, initializing it as a Git repository and pulling in all the data from the remote repository.

"Forking" is not a command within the Git software itself but a feature offered by hosting services like GitHub, GitLab, and Bitbucket. When you fork a repository, you create a copy of the original repository (the "upstream" repository) on the server side, under your own account.

This allows you to make changes independently of the original repository. Forking is commonly used to propose changes to someone else's project or to use someone else's project as a starting point for your own idea.

On GitHub, you can fork a repository by navigating to the repository's page and clicking the "Fork" button. This creates a copy of the repository under your GitHub account.

  • Ownership and Location: Forking creates a new repository under your account on the hosting service, allowing you to work independently of the original project. Cloning, on the other hand, creates a local copy of a repository on your machine. You can push changes back to the remote repository if you have permissions.
  • Contributing back: Forking is a two-step process for contributing to someone else's project. First you fork the repository to your account, then clone it to your local machine. After making changes locally, you can push them to your fork on GitHub and submit a pull request to the original repository. Pull requests are requests sent to the maintainers of the original repository, asking them to review and potentially merge your changes into their project. In the pull request, you can specify the changes you've made, why you've made them, and any other relevant information or discussion points. On the other hand if you have direct write access to a repository and don’t need to keep a separate copy under your account, cloning alone should be sufficient.

While a fork is a server-side copy of an entire repository under your account, and a clone is a local copy of a repository, a branch is a divergent line of development within the same repository. Branches are lightweight and used to isolate development work without affecting other branches in the repository.

A mirrored repository is a read-only copy of another repository that syncs with the original, mirroring all changes. Unlike a fork, a mirror does not allow for independent development but serves as a real-time backup or public mirror of a private repository.

  • Fork when you want to contribute to a project you don’t have write access to, or you want to start a new project based on an existing project but work independently.
  • Clone when you have write access to a repository and want to collaborate directly on the project, or you want a local copy of the project to work offline or make personal changes.

For more reading on forking and how it differs from cloning, see the official GitHub documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2