Title: Patch files with TortoiseSVN
Slug: patch-files-with-tortoisesvn
Date: 2010-12-18 03:38:10
Author: Kartones
Lang: en
Tags: Development, Tools
Description: How to create and apply patch files using TortoiseSVN, which can save time by avoiding repetitive changes to files.

 <p>One concept not so known in the typical enterprise .NET world (I don´t know if in other languages like Java happens or not) is the concept of patches. A patch or diff is a file that contains a change list (of one or more files), pretty much exactly what a "<strong>svn diff</strong>" would output.</p> <p>The main use of a patch is to avoid having to redo once and again the same changes to files. To give a real example, I have a small Wordpress blog to do some tests on it, and each time I update WP it breaks because of this:</p> <p><img alt="patch example" src="https://images.kartones.net/posts/kartonesblog/svn_patch_example.png"></p> <p>My Windows hosting forces me to append <font face="Courier New">$_SERVER['DOCUMENT_ROOT']</font> to the paths because relative paths are disabled, so each update made me write again the same piece of code in the index.php file.</p> <p>Creating and applying patch files with TortoiseSVN is so easy... <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-patch.html">As the official documentation says</a>, just choose <em>Create Patch </em>instead of <em>Commit</em>  when you have changes, save the patch into a file, and then when you need to apply it, <em>Apply Patch</em> (folder level, even if the patch affects just one file the context menu option only appears right-clicking on folders).</p> <p>Until I started to use Subversion I had just heard about this concept, but thought was not so useful (I was using Visual SourceSafe so my <acronym title="Source Code Control">SCC</acronym> world was pretty narrow). Now I'm slowly starting to build patches for some common tasks, specially for opensource projects that get frequent updates.</p>