Git fork

Git fork is a process of creating a personal copy of a repository on a remote Git hosting platform, such as GitHub. The forked repository is a separate, standalone repository that acts as an exact copy of the original repository. This allows you to work on your own version of the code, make changes, and create pull requests to the original repository, if you would like to merge your changes back into the original code. To fork a repository, you simply navigate to the repository on the remote Git hosting platform and click the “Fork” button. This creates a copy of the repository under your account and you can clone this copy to your local machine to start working on it.

How to Fork a Repository?

Here are the steps to fork a repository:

  1. Go to the repository you want to fork on GitHub and click the “Fork” button on the top-right corner of the page.
  2. Select your GitHub account as the destination for the repository.
  3. The repository will be forked and the new repository will be created in your account.
  4. Clone the forked repository to your local machine.
  5. Once the repository is cloned, you can start making changes and contributing back to the original repository through a pull request.

Note: It is a good practice to regularly sync your fork with the original repository to keep it up-to-date.

Here is an example of how you can fork a repository:

  1. Go to the repository that you want to fork on GitHub.
  2. Click the “Fork” button on the top right corner of the page.
  3. Choose the account where you want to fork the repository.
  4. Wait for the repository to be forked to your account.
  5. Clone the repository to your local machine using Git clone.
  6. Add the original repository as a remote using git remote add upstream [original repository URL]
  7. Keep your fork synced with the original repository by regularly pulling changes from the upstream remote using git pull upstream [branch name].

With this, you can make changes to your own copy of the repository, create pull requests, and contribute back to the original repository.

Git Fork vs. Clone

Fork and clone are two different operations in Git.

“Fork” refers to creating a new repository that is a copy of an existing one on a hosting platform like GitHub. Forks allow you to make changes to the code without affecting the original repository. Once you make changes, you can submit a pull request to the original repository’s maintainers to incorporate your changes.

“Clone” refers to making a local copy of a repository on your computer. Cloning a repository downloads all the code and its entire history to your computer, allowing you to work with it offline. You can also make changes to the code, commit them to the local repository, and push them back to the remote repository if you have the proper permissions.

Here’s an example:

  1. You find a repository on GitHub that you’re interested in contributing to.
  2. You click the “Fork” button on the GitHub page to create a fork of the repository in your own GitHub account.
  3. Now you have a copy of the repository in your GitHub account, so you can clone it to your local machine.
  4. On your local machine, run the following command in the terminal or Git Bash: git clone
  5. Now you have a local copy of the repository on your computer, and you can start making changes.
  6. After you’ve made changes and committed them to your local repository, you can push them to your remote repository on GitHub.
  7. Finally, you can submit a pull request to the original repository maintainers, asking them to merge your changes into the original repository.
Content Protection by
Please Share