Thursday, May 1, 2008

Ignoring files with SVN

This is one of those things that I've just never really got my head around. I'm not sure why, I suppose I just never took the time to read the manual. Stupid me!

After filling up my drives on my svn host, I found that it was pretty much log files that were killing me, so now I needed to work out how to do it. You'd think it would be simple, something like svn ignore log/development.log, but noooo.

I won't rant to much here about what svn propset and svn propedit do, you can read the manual page here

Short of it all is follow these instructions.


1. Create a file that will list all the files you want to ignore, I've called mine .svn_ignore and it is in the root of the trunk of my repository

2. Edit that file and add a list of the files you want to ignore, mine looks like this(it's for a rails project)
*.sqlite3
schema.rb
*.log
*.pid

The file is just a newline separated list of the files you want to ignore, as you can see you can use wild cards.

3. Now for the fun bit, first make sure that the files you want to ignore aren't checked in yet.
$> svn st
? log/production.log
? log/test.log
? log/development.log
? db/schema.rb
? db/development.sqlite3
? db/test.sqlite3

4. Execute the following command to ignore all of the listed(in your .svn_ignore) files.
$> svn propset svn:ignore -F .svn_ignore ./log/
property 'svn:ignore' set on 'log'

$> svn st
? db/schema.rb
? db/development.sqlite3
? db/test.sqlite3

5. Obviously you can now apply this same files to your db directory.
$> svn propset svn:ignore -F .svn_ignore ./db/

$> svn st

Happy times.