OK, first.... please no lectures on why command line is better than GUI. I went through my radical anti-GUI (who needs a mouse anyway) days back in the '80s. Oh, and yes, I know what Cygwin is -- I even have it on another one of my computers...

Has anyone found a good Windows program that reads patch files and applies them to files on Windows?

I have wasted half a day trying to find one because I am trying to install the taxonomy_access module and much to my horror, it requires applying a patch to another module.

I found this really nice, deceptively named "winmerge" which is great for making diffs but doesn't merge.

So I have installed gnu patch for now, but I dislike programs that need command line options to work properly. It's a great way to destroy the universe at 4:28 am with a typo.


bomarmonk’s picture

After messing around with a few other choices, cygwin worked for me. It does use a unix/command line interface, but I actually find that pretty direct. Although, it doesn't employ a pretty point-and-click interface.

bomarmonk’s picture

I just realized, three years later, that you didn't want to hear about Cygwin. Some help I was! Sorry about that.

Izz ad-Din’s picture


sepeck’s picture


Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
Test site, always start with a test site.
Drupal Best Practices Guide

lekei’s picture

I am using Tortoise cvs, it does not apply patch files.

vwX’s picture

Patch by hand. The +++ get added and the --- get removed.

Have fun and check my Drupal Profile: http://drupal.org/user/519

Pewter Tankard’s picture

Try the following (no guarantees... I don't use them myself but they look good):


Hope this helps

lekei’s picture

I have installed the gnu version of patch. You still have to type filenames.

If I must use command line then I must. If I had a problem with open source then I wouldn't be using Drupal. Unfortunately, I thought it (open source) meant that you could become familiar with the source code, not that it was an absolute requirement to get it to work.

I give up. I could type 1000 filenames in the time it has taken me to find a way not to. Even if I did it wrong 1% of the time and it took me 15 minutes to undo the damage each time I think I would still be ahead.

lekei’s picture

After a bit of fiddling, I found that the way to get patches to install is to use the form:

patch {file} {patch} --verbose --binary

Without --binary, you get the most useful and informative message: "assertion failed" message due to the fact that the drupal files are in UNIX format.

Additionally, to upload the edited files successfully, you should add the Drupal file extensions .patch, .module, and .theme to the list of text file types in your FTP program, so it can repair newlines when it sends them to *nix hosts.

marcushenningsen’s picture

Thank you!

Steven’s picture

Really, I'm sympathetic with you... I also think that the Unix command-line is one the biggest propagations of idiocy of the modern age, but applying a patch with the patch tool requires one command that is relatively easy to remember:patch -p0 < file.patch

If you want, you can turn this into one-click patching with a little trick. Get the native win32 version of patch.exe from the gnu tools, copy it to a directory within the system PATH. Then create a patch.bat file in the same location, with the following content:

@echo off
patch -p0 < %1

Finally, set up a file type association for .patch and .diff files which executes:patch.bat "%1"

From now on when you need to apply a patch, copy the patch file to the right location and double-click it. Or if you want, you can set up the default action to open the patch in a text-editor, with "Apply Patch" being a non-default right-click action.

With some tweaking, you can turn Windows into a very productive environment ;).

If you have a problem, please search before posting a question.

lekei’s picture

Now you see what happens when you are stuck on one way of thinking... I was ticked off because they made patch a win32 application, so you can't set it's command line parameters.

msz3544’s picture

I have installed cygwin and put the .module and .patch file in its directory. when i open the program and type anything that begins with "patch" it tells me "bash: patch: command not found" what do i do??? thanks

bonobo’s picture

didn't install the "patch" command when you installed Cygwin. In the install process, you are given a list of options to install -- I forget exactly where it is located (it's been a while since I installed cygwin) but I think it's located in "Developer Tools".

I hope this takes care of it.



manerhabe’s picture

After fixing the "assertion failed" error (details at http://drupal.org/node/60116), this worked great. Thanks!

plinky’s picture

I put the ".BAT" file in /SYSTEM32 with the following lines:

@echo off
patch -p0 < %1 --verbose --binary

Now I can just double click on ".PATCH" files.

Easy Peasy! :)

Thanks again!

aaron1234nz’s picture

You can also create .patch files just as easily..
1. Download and install diff from the GNUWin32 Project http://gnuwin32.sourceforge.net/packages/diffutils.htm

2. Navigate to the place that the exe's were installed (eg. C:\Program Files\GnuWin32\bin)

3. Create a new file called diff.bat and put the following code in the file:

@echo off
"C:\Program Files\GnuWin32\bin\diff.exe" -u %1 %2 > %1.patch

4. Go to the Start menu->Run and type "sendto"
5. Create a shortcut of diff.bat in this folder
6. You can now create a diff file by selecting both the original and modified file with your mouse, right click ON THE ORIGINAL file and choose diff.bat. A new .patch file will be created.

Alan D.’s picture

I've had a number of IDE's that can handle patches. Eclipse is one such example, and works a treat.

Alan Davison
kenorb’s picture

I'm using Eclipse/Aptana only for patching, but it crashing very often, so I'm sick if I need to run it only for patching.
WinMerge/SVNTortoise to apply patches based on SVN repositories, but CVSTortoise doesn't have any patch utils (like in SVN version) and even just on filesystem it's not working quite well.
Ported Patch version doesn't work on Vista (it's asking for a permission, but it popup additional window ignoring console arguments).
You can try with admin console, but often it's crashing or making: Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354, so you need to convert your patches into CR-LF, so it making more complicated.
Manually you can change small patches, but not more complicated, so it not make sense.
Any other simpler sugestions? I'm interested with patching, not making a patch.

hoobuba’s picture

Install the package aaron1234nz mentioned.

I run command

patch -i foo.patch --verbose --binary

I have just patched the gmap module this way

Robin van Emden’s picture

Since I currently have to patch and diff files in Windows 7 x64, I have started to use the following three batch files together with GnuWin32 diff and patch executables:

diff.bat (shortcut to the batch file used in "sendto": you can now create a diff file by selecting both the original and modified file with your mouse, right click ON THE ORIGINAL file and choose diff.bat. A new .patch file will be created - thanks aaron1234nz) :

@echo off
"C:\Program Files (x86)\GnuWin32\bin\diff.exe" -u %1 %2 > %1.patch

diffR.bat (shortcut to the batch file used in "sendto": you can now create a diff file by selecting both the original and modified directory with your mouse, right click ON THE ORIGINAL file and choose diff.bat. A new .patch file will be created) :

@echo off
"C:\Program Files (x86)\GnuWin32\bin\diff.exe" -urp %1 %2 > %1.patch

patch.bat (link the .patch extension to this batch file, remove "@echo off" if you want to see the feedback - thanks hoobuba) :

@echo off
patch --verbose --binary -p0 -i %1
izmeez’s picture

Yes, I use the same approach of batch files with Unxutils.

Using the sendto and right click for Diff works fine but I have found the file manager determines which file is %1 and which is %2 in different ways depending on the current sort order of the file manager. My use case requires ensuring the file manager sort places the original file above the newer file. It's handy for quick diff's but calling the the batch files from the command line is still needed to create diff from different "root" as required for core patches or contrib patches if the changed file is in a sub-folder.

I decided to use Unxutils because it is not dependent on extra dll files and if I am only using patch and diff I don't need to worry about adding it to the windows path. This way it can be used as a portable app on a usb key.

I also found the Tofrodos utility is a good, free tool to remove the CR from files if patches are going to be uploaded to drupal.org. It can be used to convert files both ways, either remove or add the CR. http://www.thefreecountry.com/tofrodos/index.shtml

Thanks to everyone for the tips, this thread has also been a helpful one for me.


Lasac’s picture

I tried the patch.bat but when i open the patch file with patch.bat i get the following

C: \ Program files \ Common files \ Adobe \ Adobe Version Cue CS4 \ Client \ 4.0.1> patch - verbose - binary-p0-i "C: \ Users \ Michal \ Desktop \ content_profile_6.x_redirect_option_1.2.patch "
Patch is not recognized as an internal or external command, program, or batch file.

C: \ Program Files \ Common Files \ Adobe \ Adobe Version Cue CS4 \ Client \ 4.0.1> pause
Press any key to continue. . .
jspraul’s picture

More options to try; sorry I don't know for sure that any support applying .patch files.


edit: Further down on the page it mentions jEdit's ability to apply .patch files.

jEdit is Java heavy but it's not Eclipse heavy; it seems as though it is trying to implement the desired functionality.

1. install and run jEdit
2. install JDiff Plugin
- menu: Plugins | Plugin Manager
- change to tab: Install
- check: JDiff Plugin
- click: Install
- click: Close
3. configure JDiff Plugin
- menu Plugins | JDiff Plugin | check: Dual Diff
4. open file to patch
- (will be loaded in both edit panes)
5. apply patch
- menu: Plugins | JDiff Plugin | Apply Patch...
- select .patch file (click: Browse or paste in full path)
- click: Ok
6. review changes made and save as desired
- (if it works)

... I had problems here because it seemed it didn't work right; it had problems applying a multi-file patch to a single file, and it said it did not support a .patch file I generated using Tortoise SVN.

It took me a while to find which plugin implemented this functionality; I hope it works for someone. Here is a page with a lot more detailed info (someone obviously loves jEdit):


matdab’s picture

jspraul, I've got a multi-file patch - can u tell me the secret please? I've wasted a few hours not finding solution for jEdit..

WorldFallz’s picture

Xomby’s picture

I got gnuwin32 patch.exe to work perfectly on windows 7 x64 in what I feel is the most absurd way ever...

simply put... running it from a .bat file (so I just double click on patch files)... I was plagued by the UAC garbage that everyone else in the world ran across...

The solution:
rename patch.exe to something else... like pch.exe... as long as it doesn't contain the word "patch"... then rename your bat file to also not be "patch" (just for good measure). I haven't tested this on Vista or Win7 x32, but the theory is sound.
BTW, as soon as I rename it back to patch.exe, I have issues with UAC again. Apparently this is some heuristic protection scheme by UAC...

logisch’s picture

you can use this win32 native port of the patch utiltity: http://unxutils.sourceforge.net/

it comes along with a bigger selection of other utilities and in contrast to cygwin and similar it does not need any DLLs or similar. just pick your tiny executeable of choice and store it wherever you want.

simple usage: patch.exe -i [filename]

get more help: patch.exe --help

bonobo’s picture

Given that this original post was in 2005, and that Windows XP is no longer supported (yippee!), I would strongly recommend that anyone looking for the range of utilities (like patching) offered within linux use a tool like VirtualBox: https://www.virtualbox.org/

It's open source, runs in Mac, Windows, and Linux, and is generally a useful option for a range of development scenarios.