我想知道做一个项目的Fork和做一个克隆之间的区别。
如果我已经分叉了一个项目,我只能通过GitHub发送拉请求吗?
我想知道做一个项目的Fork和做一个克隆之间的区别。
如果我已经分叉了一个项目,我只能通过GitHub发送拉请求吗?
当前回答
简而言之,“fork”创建了一个托管在你自己的GitHub帐户上的项目副本。
“克隆”使用git软件在您的计算机上下载源代码和它的整个版本历史到该计算机
其他回答
基本上,是的。fork只是请求GitHub克隆项目,并在你的用户名下注册它;GitHub还跟踪两个存储库之间的关系,因此您可以可视化两个项目(以及其他分支)之间的提交和提取。
即使您不使用fork,您仍然可以请求人们从您克隆的存储库中提取,但您必须自己处理使其公开可用的问题。或者向开发人员发送补丁(参见git format-patch),他们可以应用到他们的树。
GitHub上另一个奇怪的微妙区别是,对fork的更改不会计算在你的活动日志中,直到你的更改被拉到原始的回购中。更重要的是,要把一个分叉变成一个合适的克隆,你必须联系Github支持,显然。
摘自:为什么我的贡献没有出现:
Commit was made in a fork Commits made in a fork will not count toward your contributions. To make them count, you must do one of the following: Open a pull request to have your changes merged into the parent repository. To detach the fork and turn it into a standalone repository on GitHub, contact GitHub Support. If the fork has forks of its own, let support know if the forks should move with your repository into a new network or remain in the current network. For more information, see "About forks."
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.
简而言之:
Fork & Pull模型允许任何人对现有的存储库进行分叉,并将更改推到他们自己的分叉,而不需要对源存储库授予访问权限。然后,项目维护者必须将更改拉入源存储库。
请注意,在fork之后,您可以在您的机器上本地克隆您的存储库(在您的名称下的存储库)。对其进行更改并将其推送到您的分叉存储库。但是,为了在原始存储库中反映您的更改,您的pull请求必须得到批准。
还有一些有趣的讨论
git的分叉实际上是git的克隆吗?
我如何更新一个GitHub分叉库?
@AniketThakur的回答很好。下面这个问题还没有人回答。
如果我已经分叉了一个项目,我只能通过GitHub发送拉请求吗?
不。如果您是存储库的贡献者,您可以:制作本地克隆。创建本地分支。向该分支添加提交。将本地分支推回github(在此过程中创建远程分支)。创建一个pull请求,请求将该分支合并到主分支(或任何您喜欢的分支)中。
简而言之,分叉可能与“在你的GitHub ID/配置文件下克隆”相同。显然,除了少数例外,任何时候分叉都比克隆好。与克隆存储库不同,fork存储库始终与原始存储库进行监视/比较。这使您能够跟踪更改,发起拉请求,并手动将原始存储库中的更改与您的分叉存储库同步。