git 下载 Github 拉取请求作为统一差异

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6188591/
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-10 11:02:44  来源:igfitidea点击:

Download Github pull request as unified diff

gitversion-controlgithubdiff

提问by Thilo

How can I download the changes contained in a Github pull request as a unified diff?

如何将 Github 拉取请求中包含的更改下载为统一差异?

回答by Simone Carletti

To view a commit as a diff/patch file, just add .diffor .patchto the end of the URL, for example:

要将提交查看为 diff/patch 文件,只需添加.diff.patch到 URL 的末尾,例如:

回答by thakis

Somewhat related, to let git download pull request 123 and patch it into mylocalbranchlocally, run:

有点相关,要让 git 下载 pull request 123 并将其修补到mylocalbranch本地,请运行:

git checkout -b mylocalbranch
git pull origin pull/921/head

回答by Bill Hollings

To get the PR changes into your local repo in an staged but uncommitted state, so you can review:

要将 PR 更改以暂存但未提交的状态放入您的本地存储库,您可以查看:

git pull origin pull/123/head --no-commit

And to generate a patch file from that:

并从中生成补丁文件:

git diff --cached > pr123.diff