How to Fork a Repo in GitHub

How to Fork a Repo in GitHub

Sometimes you find really awesome open-source projects on GitHub that you want to make your own changes or additions to. Perhaps you want to use part of the code and alter it to suit your purposes. 

You might know that a Git clone can come in handy for making direct changes to a repo, provided you have permission to contribute to it. But when you just want to work on your own, independent version of a repository, then using Git fork is the way to go.

So, in today’s guide, we’ll show you how to fork a repo in GitHub. Let’s get started!

Method 1: Forking a Repository Through GitHub

While you can always use terminal commands to interact with Git, sometimes you want a more visual approach. If you don’t want to use the terminal, then the next best option is to use GitHub’s online interface. 

Step 1: Navigate to the Repo you Want to Fork in GitHub

The first thing you want to do is find a repository to fork. Check out our GitHub search article for tips on finding new repositories to check out.

Once you find a repo that you want to fork, open the repository page and hit Create a new fork, between the Unwatch and Starred buttons.

Step 2: Name your Fork, and Give it a Description

On the next screen, you can give your new fork a name. It will start with the owner of the fork, which will now be you!

You can also give your fork a description. If you only want to copy the main or master branch, make sure that box is checked. Then just hit Create fork.

And that’s it! Forking a repository on GitHub is super simple.

Method 2: Forking a Repository Through Terminal

What if you want to fork a repo through your terminal? You can certainly do that too. You’ll need to install and set up GitHub CLI and configure your personal access token first.

Once that is done, you simply copy the name of the repository you want to fork. This is the repository name:

Then, enter the following command in your terminal, replacing REPOSITORY with the name of whatever repo you are forking.

gh repo fork REPOSITORY

Final Thoughts

Hopefully, you were able to successfully fork a repo in GitHub. If you have any questions or need any help, feel free to drop a comment below!