我如何下载包含在Github拉请求作为一个统一的差异的变化?
当前回答
对于相关的解决方案,还有另一种替代方案。它回答了最初的问题,并使用git fetch和FETCH_HEAD。
git fetch origin pull/921/head
cat .git/FETCH_HEAD
# Then either of
git diff `git merge-base FETCH_HEAD HEAD`..FETCH_HEAD > diff.diff # Downloads the unified diff as asked in the original question
git merge FETCH_HEAD # Applies the diff
其他回答
要将提交文件视为diff/patch文件,只需在URL末尾添加.diff或.patch,例如:
https://github.com/weppos/whois/pull/90 https://github.com/weppos/whois/pull/90.diff https://github.com/weppos/whois/pull/90.patch
有点相关,让git下载拉请求123并在本地将其补丁到mylocalbranch,运行:
git checkout -b mylocalbranch
git pull origin pull/921/head
要将PR更改以阶段性但未提交的状态放入本地回购,您可以查看:
git pull origin pull/123/head --no-commit
然后生成一个补丁文件:
git diff --cached > pr123.diff
对于相关的解决方案,还有另一种替代方案。它回答了最初的问题,并使用git fetch和FETCH_HEAD。
git fetch origin pull/921/head
cat .git/FETCH_HEAD
# Then either of
git diff `git merge-base FETCH_HEAD HEAD`..FETCH_HEAD > diff.diff # Downloads the unified diff as asked in the original question
git merge FETCH_HEAD # Applies the diff
推荐文章
- 如何在Visual Studio中删除未推送的外向提交?
- Git在两个不同的文件之间的差异
- 我如何使用vimdiff来解决git合并冲突?
- 如何将更改提交到另一个预先存在的分支
- 为什么使用'git rm'来删除文件而不是'rm'?
- 我如何安装imagemagick与自制?
- 致命:git-write-tree:错误构建树
- Git克隆远程存储库的特定版本
- git隐藏的意图用例是什么?
- 从远程Git存储库检索特定的提交
- 如何配置git bash命令行补全?
- 我如何迫使git拉覆盖每一个拉上的一切?
- 撤销“git add <dir>”?
- 是否可以在不先签出整个存储库的情况下进行稀疏签出?
- 如何移除SSH密钥?