Drupal, How To Apply a Patch With Git - a/b Patch.

Patch files are usually handy fixes for drupal modules that haven't been released as part of the official module release. You usually come across them under the "issues" or "bug reports" area of the drupal webpage for that module. Here are some instructions on how to apply one to a module.

I had a very hard time figuring this out. I couldn't find much documentation and no step by step guides. This goes over how to do it locally on a windows machine.

1. Download and install Git from here: http://git-scm.com/downloads
2. Download whatever module you want to apply a patch to. In this example it will be jcarousel
3. On your desktop, create two new folders called a and b.
4. Duplicate the contents of the jcarousel folder into BOTH a and b folders. So you have duplicates of all module files for jcarousel in both folders.
5. Delete the contents of the jcarousel folder, then copy both folder a, and folder b, into the empty jcaorusel folder.
6. Put whatever .patch file you want to use into the jcarousel folder, so you have three files. The .patch file, folder a, folder b.
7. Open the Git command window and navigate to the jcarousel folder with this command:

hit enter. "user" is your windows account name, so mine is

8. Type: ls (for list) then hit enter to verify you are in the right spot. You should see a, b, and somepatch.patch.
9. Run this command to patch:
 patch -p0 <somepatch.patch

10. It should say the files have been patched. You have a patched copy of the module in folder a, and the original unpatched module in folder b.

Hope this helps. Took me way too long to figure out.


David Rankin