We’ll look at this in detail in the next chapter, but for now, let’s fix one thing to make things easier for us going forward. As mentioned, one of these use-cases include contributing to the original project, the one that I forked initially.
I can now use it for whatever I intended (providing that the license of the original project allows my use-case, of course). Using the URL from GitHub I run the following command to create a local clone of the repository: $ git clone the code is available locally on my computer. If you’ve set up an SSH key for your GitHub account, you can use SSH, otherwise, choose HTTPS. By going to my fork on GitHub and clicking “Clone or download”, I get a URL for the repository. To work with the code locally, I need to clone the repository just like I would clone any other repository. Now I have a fork of the original repository in my own GitHub account. If I’m a member of some organizations, I get to choose where to fork the repository - I’m going to select my own user account. To create a fork - my own copy - of this repository, I just press the “fork” button in the upper right of the screen. For now, let’s look at creating a fork and cloning it locally in GitHub.īelow, I’m looking at a repository in GitHub. We’ll look at pull requests in the next chapter.
In this case, a pull request is often used to integrate the changes into the original repository. Developers can fork the project and push code to their own forks instead of the original repository, while a maintainer is responsible for integrating the changes into the original repository. While there are other ways to do this, like pushing directly to its repository or mailing patches around, a fork-based workflow is convenient as it allows you to use the familiar concepts of branches and remotes in Git without having write permissions in the original repository. Contributing to a Project Through a ForkĪs mentioned, a common use-case for a fork is to contribute to a project. GitHub, Bitbucket and GitLab all offer forking functionality. A fork can be thought of as a server-side clone of a repository, whatever the mechanism behind the fork really is. The fork will also “know” from which repository it has been forked. Put simply, a fork of a repository is a copy of that repository, with all its code, branches and history, on the server.
The fact that the Ruby on Rails project has over 18,000 forks on GitHub at the time of writing doesn’t mean that there are 18,000 competing versions of Rails out there.Ī fork is not a built-in feature in Git itself, but rather a concept provided by several Git hosting services. Furthermore, a fork can be used to include a project in your own codebase with some modifications, or just to play around with a project. While a fork can be used as a basis for a separate project, a fork is also often used to contribute to the original project. In the world of Git, the meaning is similar but the connotations are different. In this context, the term “fork” carries some negative connotations, as forking a project can mean that the community of developers and users of the original project splits into two groups. In the world of open source, forking a project has traditionally meant that someone took the project’s current code base and used it as a basis for a separate, alternative project. Learn on: Desktop GUI | Command Line Language: EN Forking