<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Smartkey - Java Software Consultancy &#187; Ignore</title>
	<atom:link href="http://blog.smartkey.co.uk/tag/ignore/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartkey.co.uk</link>
	<description></description>
	<lastBuildDate>Tue, 13 Dec 2011 15:03:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ignoring Files and Directories in a Subversion Project</title>
		<link>http://blog.smartkey.co.uk/2009/12/ignoring-files-and-directories-subversion/</link>
		<comments>http://blog.smartkey.co.uk/2009/12/ignoring-files-and-directories-subversion/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 11:58:07 +0000</pubDate>
		<dc:creator>Steve Neal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tool support]]></category>
		<category><![CDATA[Ignore]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://blog.smartkey.co.uk/?p=566</guid>
		<description><![CDATA[Configuring Subversion to ignore files can sometimes cause confusion. Like most things though, if you understand the basic principles, then its not tricky at all. In this post I'll demonstrate just how you should go about ignoring files in a subversion project. ]]></description>
			<content:encoded><![CDATA[<p>Configuring Subversion to ignore files can sometimes cause confusion. Like most things though, if you understand the basic principles, then its not tricky at all. In this post I&#8217;ll demonstrate just how you should go about ignoring files in a subversion project.</p>
<p>There are two ways to ignore files in svn: global settings and local. Global settings configure the users environment with some rules for ignoring files, but generally the local ignores are more useful and will be discussed here.</p>
<p>Most projects have files that should be ignored and not included in the version repository. For example, in Java projects, the compiler output shouldn&#8217;t be included as these can be regenerated from the source anyway. You might also have temporary cache files being generated, or output from running unit tests that you don&#8217;t want to share too.</p>
<h3>Ignoring files and directories</h3>
<p>Each directory in a svn managed project has a sub-directory called .svn which contains configuration information that svn uses when working in that directory. To make svn ignore certain content within a directory you need to configure an <strong>svn:ignore</strong> property for it.</p>
<p>To demonstrate this let&#8217;s work with the following project directory structure:</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">myproject/build/classes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">myproject/log.txt</div>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">myproject/log-2009-12-01.txt
myproject/log-2009-12-02.txt
myproject/build/classes</pre>
<p>First let&#8217;s tell svn to ignore the log files that have been created. I&#8217;m using SVN 1.5.4 on a Mac so I&#8217;ll demonstrate this using a command line but you could do much the same using a GUI tool like Tortoise:</p>
<pre>$ svn propset svn:ignore 'log-*.txt' myproject</pre>
<p>The above command has used the <strong>propset</strong> command to set the <strong>svn:ignore</strong> property value to <strong>log-*.txt</strong> for the <strong>myproject</strong> directory.</p>
<p>Note that it is possible to use a wild-card &#8216;*&#8217; as part of the file name. You can also use the &#8216;?&#8217; symbol to match a single character in a file name but svn does not currently support any more powerful matching features.</p>
<p><em>Importantly note also that the file name must be quoted in order that the literal value is passed to the svn command; without this the shell will process the wild-card and pass all matching file names instead.</em></p>
<p>You can inspect the value of this property using the propget command like this:</p>
<pre>$ svn propget svn:ignore myproject
log-*.txt</pre>
<p>An ignore property can also be applied to directories, causing all files and sub-directories within it to be ignored. To make svn ignore the classes directory and its contents we could use the command:</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">$ svn propset svn:ignore 'classes' myproject/build</pre>
<h3>Setting multiple ignore rules within a directory</h3>
<p>So far we&#8217;ve looked at how we can set an individual ignore rule within a directory using the <strong>propset</strong> command. Although both of the rules we&#8217;ve demonstrated have resulted in multiple files being ignored, either by using a wild card syntax or by specifying a directory whose content will also be ignored, we&#8217;ve not yet discussed is how these rules can be combined within a directory; for example: to ignore all log files and also a sub-directory:</p>
<pre>/myproject/log-2009-12-01.txt
/myproject/log-2009-12-02.txt
/myproject/classes</pre>
<p>The <strong>svn:ignore</strong> property is actually a list of file name patterns that svn must ignore. The propset command simply overwrites that list with a single line that includes the pattern you specify when you issue the command.</p>
<p>To create a list of file names that will be matched, use the <strong>propedit</strong> command instead:</p>
<pre>$ svn propedit svn:ignore myproject</pre>
<p>Your svn editor will then be started and you can edit the list of filenames that must be ignored. For our example it would need to look like this:</p>
<pre>log-*.txt
classes</pre>
<p>Note that each file name pattern must be on a separate line.</p>
<h3>Ignoring versioned files and directories</h3>
<p>You must be aware that the <strong>svn:ignore</strong> properties only apply to any files that are <em>not</em> under version control.</p>
<p>In practical terms this means if you accidentally add a file or directory to your version control, you will need to explicitly issue a svn delete command (rm) in order that svn will ignore the files.</p>
<p>Commands like <strong>add</strong> and <strong>import</strong> work recursively in svn, so it&#8217;s easy to accidentally add files like those mentioned above to a versioned project. For example if our log files were accidentally added we could issue this command to delete them from svn:</p>
<pre>svn rm log*.txt</pre>
<p>Note this time that the filename is not quoted as we want the shell to pass all log files to be deleted.</p>
<p>After committing the changes to the project, the files will no longer be managed by svn and the ignore properties will once again work.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.smartkey.co.uk/2009/12/ignoring-files-and-directories-subversion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

