Patching files using DIFF/PATCH in windows

If you are maintaining any application, especially the pervasive opensource applications that are constantly changing, you need to periodically patch your application. Int he Linux/Unix world, it is second nature to make changes generate a DIFF file, and apply a patch. But when you are using Windows,and are chronically used to a GUI for everything, this can be a stumbling block. I will admit that for a long time, I either ignored patches and just turned off unnecessary features to avoid security compromises, or manually sifted through the patch.file and applied the patch by hand.

There are some applications that make it as easy to patch applications in Windows. GNUWin32 is a freely available application for windows that you can use to apply patches from the command prompt. This is downloadable from http://gnuwin32.sourceforge.net/packages/patch.htm
Once downloaded and installed, you will need to add the folder structure for this application to your Windows %PATH% settings from in the Windows configuration (You should know this as a good Windows use, or access it from the control Panel). This will allow you to call the patch application from any folder (you will need to reboot Windows once you modify the %PATH% settings).

Patching files

Once you have your patch application installed and working, you can use the following command sequence to patch your files

patch -b original.file patch.file

This simple command will create a backup of the original.file, apply the patch using the specified patch.file

demo of a simple patch operation from the Windows Command-prompt

NB: The patch application comes with a useful and complete listing of all the switches that you can use (like -b) to make the application do certain things as it patches one or more files

Valid XHTML 1.0 Strict
This site is accepts Oped ID authentication for login
This Website is Built Using Semantic Markup and Cascading Style Sheets (CSS)
Some usage rights are reserved, please contact us for approval before using it