Apply a patch from Github

Intro

This short guide explains how to apply a patch from a github pull request to another repo.

Download the patch file:

You can access a patch file by appending .patch to a pull request url:

https://github.com/example/example/pull/15.patch

Save this file wherever you like.

Steps to applying patch:

First the stats:

$ git apply --stat a_file.patch

Then a dry run to detect errors:

$ git apply --check a_file.patch

Finally, you can use git am to apply your patch: it allows you to sign off an applied patch.

This can be useful for later reference.

$ git am --signoff < a_file.patch