What is the difference between Forking and Cloning on GitHub?

后端 未结 9 1251
耶瑟儿~
耶瑟儿~ 2020-12-04 05:14

I\'d like to know the differences between doing a Fork of a project and doing a clone of it.

Can I only send pull requests via GitHub if I\'ve forked a

相关标签:
9条回答
  • 2020-12-04 05:53

    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.

    0 讨论(0)
  • 2020-12-04 05:53

    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).

    0 讨论(0)
  • 2020-12-04 05:54

    In a nutshell, "fork" creates a copy of the project hosted on your own GitHub account.

    "Clone" uses git software on your computer to download the source code and it's entire version history unto that computer

    0 讨论(0)
提交回复
热议问题