Download Github pull request as unified diff

GitVersion ControlGithubDiff

Git Problem Overview


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

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

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

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

Solution 3 - Git

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

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

And to generate a patch file from that:

git diff --cached > pr123.diff    

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionThiloView Question on Stackoverflow
Solution 1 - GitSimone CarlettiView Answer on Stackoverflow
Solution 2 - GitthakisView Answer on Stackoverflow
Solution 3 - GitBill HollingsView Answer on Stackoverflow