我如何下载包含在Github拉请求作为一个统一的差异的变化?
要将提交文件视为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