Creating patch from GitHub pull request
Have you ever needed to generate a patch file from a GitHub pull request? If you answered YES, you'll enjoy this little hidden feature.
Every pull-request on GH can be downloaded as a beautiful mail-patch, just by appending ".patch" to the pr URL.
E.g., from:
https://github.com/php/php-src/pull/296
To:
https://github.com/php/php-src/pull/296.patch
This will generate a mail-formatted patch file, that is a little different from an usual patch file: It has e-mail metadata.
After downloaded, apply the result patch using:
$ git am 296.patch
Related protips:
Written by Willy Barro
Related protips
6 Responses
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/108731/66c0cc63afb786af6c17d40198166222.png)
THANK YOU! You made my day
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/120057/none.jpg)
Thanks! That's exactly what I was looking for!
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/121619/none.jpg)
Thank you! That worked great!
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/93169/Ariel_Caplan_pic.png)
Just what I needed today, thank you!
Thank you. What's the difference between git am file.patch
and git apply file.patch
in this context?
I signed up to say THANKS. Kudos mate 💪🏽