Sometime you might want to test pull requests (from github) in local machine by cherry picking it. This usually happens before it get merged in the upstream repo and released by the project.
I searched the internet but did not get good reference about how to do it. After little bit of trial and error I came up with below steps.
Cherry picking a pull request:
For example you want to cherry pick https://github.com/fgrehm/vagrant-cachier/pull/164
- Copy the pull request url, append “.patch” and open it in a browser.
e.g. https://patch-diff.githubusercontent.com/raw/fgrehm/vagrant-cachier/pull/164.patch - It will automatic resolve as something like below
https://patch-diff.githubusercontent.com/raw/fgrehm/vagrant-cachier/pull/164.patch - Use the new url for cherry picking the patch on your local repository
$ curl https://patch-diff.githubusercontent.com/raw/fgrehm/vagrant-cachier/pull/164.patch | git am
Cherry picking a commit:
- Get url for the commit
example: https://github.com/LalatenduMohanty/vagrant-cachier/commit/081c809fc369210c6bb06ad9786b8f9be4fb8570 - Append “.patch” and and use it for patch the local code.
$ curl https://github.com/LalatenduMohanty/vagrant-cacrhier/commit/081c809fc369210c6bb06ad9786b8f9be4fb8570.patch | git am
Thanks! Useful tips.