Applying Patches

---------------- NEEDS TO BE EXPANDED/REVIEWED ----------------------

Applying patches, modifying files according to instructions in the patch file, is the domain of patch programs. There are many different programs with this functionality. some stand-alone (patch), some integrated in IDE's (Eclipse, XCode).

Warning: Patching is something that should never be done on your production site unless you have sufficient backup and testing performed. While patching itself is relatively easy, understanding the implications of a patch is not. Patching your system can lead to loss of data and/or site instabilities

This page only deals with some basic principles using the command line utility patch. Patch can be found on most UNIX systems and is included in the packages UnxUtils and Cygwin for use on Windows.

Provided that the patch was made relative to the ProjectPier root directory, navigate to the ProjectPier directory (using cd) and issue the command:

patch -p0 < path/file.patch

If the patch was not made relative to the ProjectPier root directory you can place the patch in the same directory as the file being patched and run the patch command without the -p option. To do so, cd to the directory and type:

patch < file.patch

Patch will usually auto-detect the format. You can also use the -u command line option to indicate a unified patch, and the -b option creates a backup copy of the file before modifying it. In case of problems, you can then easily restore the backup file.

You can also reverse the patch if you want to.

You will need shell/ssh access to your server. Your account needs to have the proper permissions, and you need to access it through the command line.

  • ftp the patch file to the same directory as the file that you want to patch.(or to the root ppier directory if more than one file)
  • issue the command:

    patch -b < file_name.patch

  • You're Done - Check the changes to the site.

The -b option creates a backup of the original file(s) that are modified by the patch command (they will have a .orig extension added). If anything goes wrong on the site, it's easy to restore the files to their original state.

More information:The Ten Minute Guide to diff and patch

Does anyone know a similiar site for doing this using a GUI (like Tortoise SVN)?

TortoiseSVN is just a matter of right clicking the root folder, choosing apply patch and choosing the file. Same thing for creating a patch, except you'll name a new file. You can also easily see it in the TortoiseSVN help.

-Ryan