git 我如何接受 GitHub 拉取请求并将其作为单独的项目下载?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20342658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:24:49  来源:igfitidea点击:

How do I take a GitHub pull request and simply download that as a separate project?

gitgithub

提问by Doug Smith

Say I have this pull requestand I want to download it as if it was its own separate project. How do I go about doing that? I don't see any button for that functionality.

假设我有这个拉取请求,我想下载它,就好像它是它自己的独立项目一样。我该怎么做?我没有看到该功能的任何按钮。

采纳答案by Noufal Ibrahim

You can download a snapshot of the tree at that commit over here. This is an exported tarball so you won't have any history. Is that what you're looking for? You can get to this by first looking at the commits he wants you to pulland then picking the latest one in the list. Navigating to this URL will give you the diff (i.e. it's examining the commit object rather than actual tree). You can now simply change the commitin the above url to treeor click on the "Browse code" button. Once you do that, there's a "Download ZIP" button on the right which allows you to download the tree.

您可以在此处下载该提交时树的快照。这是一个导出的 tarball,所以你不会有任何历史记录。这就是你要找的吗?您可以通过首先查看他希望您提取提交,然后选择列表中最新提交来实现这一点。导航到此 URL 将为您提供差异(即它正在检查提交对象而不是实际树)。您现在可以简单地commit将上述网址中的更改为tree或单击“浏览代码”按钮。完成此操作后,右侧有一个“下载 ZIP”按钮,可让您下载树。

If you want complete history, then you need to fetch mlwelles changes. You can do this by going to the mlwelles:masterrepository over hereand adding that as a remote to your own local clone using git remote add mlwelles [email protected]:mlwelles/AFOAuth2Client.git. Then you can fetch the changes he's asking you to merge using git fetch remote master. The changes will be available in FETCH_HEAD. You can either view them using git checkout FETCH_HEADand git log(or whatever), view the diffs using git diff FETCH_HEAD(against your current branch) or finally integrate the changes he's asking you to using git merge FETCH_HEAD. Once you do this, you can push the changes to your own repository using git push origin master(assuming the original repository is added as origin).

如果您想要完整的历史记录,那么您需要获取 mlwelles 更改。您可以通过转到此处mlwelles:master存储库并将其作为远程添加到您自己的本地克隆使用. 然后,您可以使用 获取他要求您合并的更改。更改将在. 您可以使用and (或其他方式)查看它们,使用(针对您当前的分支)查看差异,或者最终集成他要求您使用的更改。完成此操作后,您可以使用(假设原始存储库添加为)将更改推送到您自己的存储库。git remote add mlwelles [email protected]:mlwelles/AFOAuth2Client.gitgit fetch remote masterFETCH_HEADgit checkout FETCH_HEADgit loggit diff FETCH_HEADgit merge FETCH_HEADgit push origin masterorigin

回答by Pippin

Did you check this answeralready?

你已经检查过这个答案了吗?

Will look something like this for Michael's pull request:

对于迈克尔的拉取请求,看起来像这样:

git clone https://github.com/mlwelles/AFOAuth2Client.git -b master

which ended up giving me a clone of Michael's pull request locally.

最终在本地给了我一个 Michael 的 pull request 的克隆。

回答by mback2k

In case you are just interested in a tar or zip archive, there is actually an API for that. You can use a link like the following to download the content of the pull request:

如果您只对 tar 或 zip 存档感兴趣,那么实际上有一个API。您可以使用如下链接下载拉取请求的内容:

https://api.github.com/repos/AFNetworking/AFOAuth2Manager/zipball/pull/55/head

https://api.github.com/repos/AFNetworking/AFOAuth2Manager/zipball/pull/55/head

The important part is that the part behind the /zipball/ (or /tarball/) must be a valid git reference. For pull requests this would be pull/ID/head there ID is the pull requests ID. See step 5 of this guide.

重要的部分是 /zipball/(或 /tarball/)后面的部分必须是有效的 git 引用。对于拉取请求,这将是 pull/ ID/head,ID 是拉取请求 ID。请参阅本指南的第 5 步。