Last Updated: October 04, 2020
· willybarro

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:


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:

fatal: refusing to merge unrelated histories

6 Responses
Add your response

THANK YOU! You made my day

over 1 year ago ·

Thanks! That's exactly what I was looking for!

over 1 year ago ·

Thank you! That worked great!

over 1 year ago ·

Just what I needed today, thank you!

over 1 year ago ·

Thank you. What's the difference between git am file.patch and git apply file.patch in this context?

over 1 year ago ·

I signed up to say THANKS. Kudos mate 💪🏽

over 1 year ago ·