How can I download the changes contained in a Github pull request as a unified diff?
-
Normally the PR patch link is sent to the person, who's accepting the PR. – kenorb Jun 21 '13 at 9:15
-
This isn't implemented in GitLab yet, but I created a feature request so please add your votes to it. – colan Nov 19 '14 at 16:01
-
cf. the the last ¶ of Pro Git §6.3.3: "Managing Pull Requests: Email Notifications" – Geremia Mar 6 '17 at 14:40
To view a commit as a diff/patch file, just add .diff or .patch to the end of the URL, for example:
-
11Great, thanks. And there is also
.patch. Why is this not exposed in the GUI? How is one supposed to discover this? – Thilo May 31 '11 at 14:04 -
37It's not documented to keep stackoverflow in business. Honestly, that is FAQ #2 – sehe May 31 '11 at 14:15
-
Also because
git pullis the preferred method of downloading and applying the changes. – Tekkub Jun 1 '11 at 5:20 -
14
-
3Judging by what these return and the the links in the docs at developer.github.com/v3/media/… , the
.diffURL gives a straight diff to the default branch based ongit-diffgit-scm.com/docs/git-diff output, and the.patchURL gives a concatenation of the individual commits in the PR (each relative to their parent commit) in a format suitable for e-mailing based ongit-format-patchgit-scm.com/docs/git-format-patch output. – rakslice May 7 '17 at 0:10
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
-
10Or to get the pull request onto a new PR branch
git fetch origin pull/921/head:PRand then merge with your current branch, giving you a chance to review the changesgit merge PR --no-commit --no-ff– MoonStom Mar 4 '15 at 21:08 -
3The full documentation is at help.github.com/articles/checking-out-pull-requests-locally – JBert Feb 23 '16 at 11:22
-
This requires you to setup Git with your credentials. You cannot anonymously test a proposed change (like you could by apply a diff manually). Yet another instance of Git taking a simple workflow and making it difficult. – jww Mar 23 '17 at 18:39