While the concept of forking a GitHub repository is similar to cloning, there is an important difference between the two. We explain what the difference is, when you may want to fork instead of clone, and how to do it.
Cloning vs Forking: What’s the Difference?
When you clone a repo, you copy that repository to your local machine and are essentially subscribing to any updates made to that repo. That is, if other contributors to the repository make any changes, you can pull those changes to your local machine, updating your copy of the repository with all the changes made.
However, when you fork a repository, you’re copying the origin repository to your GitHub account instead of your local machine. When you do this, none of the updates made to the source repo will be reflected to your forked repo unless you decide to sync the two. This allows you to work on the repo without the worry of the code or content being updated.
When Should You Fork Instead of Clone?
There are a few different reasons why you may want to fork a repository instead of clone it. One reason is if you want to test some new ideas you have without the worry of accidentally messing up the source project. You’d be free to alter any code you like for testing purposes without actually touching the source code. This keeps everyone happy.
Another reason could be because you don’t agree with the direction a project is going. You could fork the repository and make your own changes to the code to take the project in the direction you think it should go.
One very important note to keep in mind is that if you fork a public repository, your fork still exists even if the origin repository is deleted. However, when a private repository is deleted, all forks of that repository are also deleted.
RELATED: How to Delete a GitHub Repository
How to Fork a GitHub Repository
Forking a repo is simple and can be done in just a few clicks. To fork a repo, log in to your account and then go to the repository you want to fork. In the top-right corner of the window, you’ll see a “Fork” button with a number to the right of it, which represents the number of times the repository has been forked. Go ahead and click that button.
A message will briefly appear letting you know that the forking process has started. It only takes a few seconds to fork the repo.
That’s all there is to it. It’s that easy.
You’re now safe to make any changes to the code in your forked repository that you like. To do so, just clone the forked repository to your local machine and get busy!
RELATED: How to Clone a GitHub Repository