I understand that forking is cloning the repository on the server side. But I don't understand why I would do that.
Why not clone the original repository to my machine, add my code, than push the new branch to GitHub and make a pull request?
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.
When you call fork , you're creating a copy of your own process that has its own address space. This allows multiple tasks to run independently of one another as though they each had the full memory of the machine to themselves.
Most commonly, forks are used to either propose changes to someone else's project to which you do not have write access, or to use someone else's project as a starting point for your own idea. You can fork a repository to create a copy of the repository and make changes without affecting the upstream repository.
Forks are best used: when the intent of the 'split' is to create a logically independent project, which may never reunite with its parent. Branches are best used: when they are created as temporary places to work through a feature, with the intent to merge the branch with the origin.
I understand that forking is cloning the repository on the server side [...]
That's about right. On GitHub, a fork is a copy of some other GitHub repo, with a reference to the repo it was copied from.
Remark: the concept of a fork originated with GitHub; it is not a Git concept.
[...] but I don't understand why I would do that. Why not clone the original repository to my machine, add my code, then push the new branch to GitHub and make a pull request?
Unless you have write access to the repository in question, you cannot simply push anything to it; your push will be denied by the server with an error message of the form
remote: Permission to bos/text.git denied to Jubobs.
fatal: unable to access 'https://github.com/bos/text/': The requested URL returned error: 403
That's where a fork comes into play. By forking someone else's repo, you get a copy to which you have write access, i.e. to which you can push your contributions. The entire workflow goes something like this:
From the Github documentation
A fork is a copy of a repository. 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.
https://help.github.com/articles/fork-a-repo/
Forking makes it clear that your repository derives from the other, by marking your repository as "forked from..." and more importantly, it will list your repository in the fork list of the original project.
One of the advantages of that is that in the event that the original project becomes discontinued while you are still working on it, people can still find your repository looking on the fork list from the main repository.
From github's point of view, they can save some disk space by knowing that the git objects between your and the original repository are the same and can be shared
Moreover, I think you cannot make a pull request from a repository which is not a fork of the original one. At least I wasn't able to do it, I had to fork, push to the fork, ask for a pull request.
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