How to Fork a GitHub Repository?
GitHub is a great application that helps you manage your Git repositories. Forking a GitHub repository is a common practice that allows you to create your own copy of a repository hosted on GitHub. In this article, we will learn more about Git-Fork and its uses.
Table of Content
What is GitHub Repository Forking?
A fork is a new repository that shares code and visibility settings with the original “upstream” repository. Forks are often used to iterate on ideas or changes before they are proposed back to the upstream repository, such as in open source projects or when a user does not have write access to the upstream repository.
How to Fork a Repo in GitHub
Step 1: Open the repository that you want to Fork there You can see the icon as shown in the image below in the repo’s top right corner. Now, this feature is used to Fork the repo.
.png)
Step 2: Go to any repository that you want to Fork here we are using a sample repo of Python official repository.
.png)
Step 3: Find the Fork button in the top right corner.
.png)
Step 4: Click on Fork.
Step 5: Now you have your own copy of the repository. But how can we confirm for which do refer to below visual aid as follows:
.png)
Now we can see your user name(**********)/mern-todo-app and also below that, we have the link to the original project I forked from.
Whatever changes are made to ‘******/mern-todo-app We can make my changes here and then make a Pull Request to the maintainers of the project. Now it is in their hand if they will accept or reject your changes to the main project.
Fork Using Command Line
Step 1: Open the terminal or gitbash and type the below command.
git --version
.png)
Step 2: You must first log in using the CLI to GitHub using your GitHub account before you may fork the repositories. To do it, issue the following command.
git auth login --web > SSH
Step 3: Once authentication is done. Copy the Repo URL that you to fork into our repo and use the below command.
.png)
gh clone <REPO URL>
.png)
Conclusion
Forking a GitHub repository enables users to create their own copy of a project. It's useful for contributing to open-source projects or experimenting with code changes. This process encourages collaboration and allows developers to maintain separate development branches while contributing back to the original repository through pull requests. Overall, forking provides community engagement and the sharing of code among developers.