我如何下载包含在Github拉请求作为一个统一的差异的变化?
要将提交文件作为diff/patch文件查看,只需在URL末尾添加.diff或.patch,例如:
.diff
.patch
有点相关,让git下载拉请求123并在本地将其修补到mylocalbranch,运行:
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
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