If you don't intend to make changes to code, clone but don't fork. Forking is intended to host the commits you make to code, while cloning is perfectly fine for copying the content and history of the project.
A fork is a copy of a repository that you manage. Forks let you make changes to a project without affecting the original repository. You can fetch updates from or submit changes to the original repository with pull requests.
Forking a repository allows you to freely experiment with changes without affecting the original project. Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea.
When you say you are Forking a repository you are basically creating a copy of the repository under your GitHub ID. The main point to note here is that any changes made to the original repository will be reflected back to your forked repositories(you need to fetch and rebase). However, if you make any changes to your forked repository you will have to explicitly create a pull request to the original repository. If your pull request is approved by the administrator of the original repository, then your changes will be committed/merged with the existing original code-base. Until then, your changes will be reflected only in the copy you forked.
In short:
The Fork & Pull Model lets anyone fork an existing repository and push changes to their personal fork without requiring access be granted to the source repository. The changes must then be pulled into the source repository by the project maintainer.
Note that after forking you can clone your repository (the one under your name) locally on your machine. Make changes in it and push it to your forked repository. However, to reflect your changes in the original repository your pull request must be approved.
Couple of other interesting dicussions -
Are git forks actually git clones?
How do I update a GitHub forked repository?
Basically, yes. A fork
is just a request for GitHub to clone the project and registers it under your username; GitHub also keeps track of the relationship between the two repositories, so you can visualize the commits and pulls between the two projects (and other forks).
You can still request that people pull from your cloned repository, even if you don't use fork
-- but you'd have to deal with making it publicly available yourself. Or send the developers patches (see git format-patch
) that they can apply to their trees.
You can commit on your online repo (or commit on your local repo and then push to your online repo), then send pull request.
Project manager can accept it to get your changes in his main online version.
A clone is where you have proper duplication, and separation between, two (possibly different) versions of a repository. When one repo is amended, the new content must be actively copied to the other repo using a push command. And changes in the other repo fetched.
When you fork a repo, on a server, there is no need for duplication of content because both repos will use the same [fixed object] content from that same server. The 'trick' is in managing the different user viewpoints so that each user believes they have a full personal copy of the repo. Pushes and fetches between forks is simply updates the user's pointers.
At a lower level, git does the same thing internally. If you have three different files, each containing Hello World
, then git simply 'forks' its single copy of the Hello World blob and offers it up in each of the three places as required.
The ability to fork on the server means that Github's large storage allowance isn't that big on average as every body shares the one single underlying repo.
While @AniketThakur's answer is very good. No one has answered the following question yet.
Can I only send pull requests via GitHub if I've forked a project?
No. If you are a contributor to a repository, you can: Make a local clone. Make a local branch. Add commits to that branch. Push the local branch back to github (creating a remote branch in the process). Make a pull request requesting for that branch to be merged into the master branch (or whatever branch you like).
In a nutshell, Forking is perhaps the same as "cloning under your GitHub ID/profile". A fork is anytime better than a clone, with a few exceptions, obviously. The forked repository is always being monitored/compared with the original repository unlike a cloned repository. That enables you to track the changes, initiate pull requests and also manually sync the changes made in the original repository with your forked one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With