2

What is the difference between forking a GitHub repository and cloning it to my local machine?

I would like to contribute to an open source library and I think the easiest way is to clone the repository and then send a pull request to the owner of the library to be reviewed. But why do other people fork repositories?

random
  • 9,774
  • 10
  • 66
  • 83
samir
  • 4,501
  • 6
  • 49
  • 76

1 Answers1

4

In order to send a pull request using the Github user interface, you have to fork a repository. (By the way, this is done automatically for you if you just want to make a trivial string/doc change using the online "Edit" feature of GitHub.)

Forking and cloning a local copy are not mutually exclusive.

You would typically do both, to build and test locally, and when happy, commit and push up to your fork.

Robin Green
  • 32,079
  • 16
  • 104
  • 187
  • Thanks. If i just clone the project and then create a branch locally, make modification and then push it the owner's repository and then create a pull request to be merged to the master, can i do like this ? – samir Nov 30 '13 at 12:35
  • 3
    You cannot push it to the owner's repository without their permission. By default, only the owner has permission to push to their repository. That is why we use forks. – Robin Green Nov 30 '13 at 12:36
  • Thanks it's clear for me. – samir Nov 30 '13 at 12:37
  • "In order to send a pull request using the Github user interface, you have to fork a repository." This is not true. One can make a pull request that requests for a branch to be pulled into another branch even if both branches are a part of the same fork. – Theodore Norvell Sep 05 '18 at 18:50
  • Sure but in the context of the question the repository to be modified is a repository that the questioner does not have commit access to. – Robin Green Sep 05 '18 at 18:54