Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply a git patch when given a pull number

I downloaded a trunk version of a codebase from git, and there are build errors. Aparently a patch is now available, and I received an email :

see https://github.com/JustinTulloss/zeromq.node/pull/47 for patch

I am new to git so I'm not quite sure what to do with this 'patch' especially, since the page looks more like a discussion thread.

Does anyone know how I can obtain/apply this patch to my locally cloned git repository?

like image 263
Homunculus Reticulli Avatar asked Oct 19 '11 19:10

Homunculus Reticulli


People also ask

How do I make a pull request patch?

Every pull-request on GH can be downloaded as a beautiful mail-patch, just by appending ". patch" to the pr URL. This will generate a mail-formatted patch file, that is a little different from an usual patch file: It has e-mail metadata.


2 Answers

Save the patch somewhere. If you're using linux you can use curl:

curl -L https://github.com/JustinTulloss/zeromq.node/pull/47.patch > /tmp/47.patch 

To apply the patch use git apply. You can see if the patch will apply cleanly with the check option. Change to your git directory and run:

git apply --check /tmp/47.patch 

If it looks like you want to apply the patch remove the check option

git apply /tmp/47.patch 
like image 143
Andrew Avatar answered Oct 05 '22 00:10

Andrew


Just add a .patch at the end to get the patch:

https://github.com/JustinTulloss/zeromq.node/pull/47.patch

You can do something like below:

$ git checkout master $ curl http://github.com/JustinTulloss/zeromq.node/pull/47.patch | git am $ git push origin master 

http://help.github.com/send-pull-requests/

like image 40
manojlds Avatar answered Oct 04 '22 22:10

manojlds