Ignoring files in subversion repositories

Submitted by kitt on Sat, 2005-06-11 01:03.

With CVS, ignoring files in a local checkout is easy. You add the file name to the .cvsignore file in the directory the file is located in. When a cvs command was issued in that directory, the files listed in the .cvsignore would be, well, ignored.

% cat .cvsignore
config.inc.local
.cvsignore

Note that .cvsignore is listed in the .cvsignore file as well. Otherwise, the file would list each time a cvs update was made:

% cvs up
? .cvsignore
U config.inc

So, ignoring files is pretty easy with CVS, right?

What happens when everyone who has a local checkout wants to ignore the same files (a common scenario when development processes create temporary, intermediate files)?

Right, each developer needs to create his own .cvsignore file in each local checkout.

Subversion handles the process of ignoring files in a local checkout differently.

Instead of creating a local ignore file, you can set an "ignore property" in a directory for a specific file or subdirectory. This property is set in the repository and is applied to all local checkouts. With this strategy, all checkouts will behave the same way (i.e. all local checkouts on the same revision will ignore the same files and subdirectories).

This is goodness. So how are these set?

svn propset svn:ignore file directory

Here, we are setting the property svn:ignore on the file file in the directory directory. The file can actually be another directory:

svn propset svn:ignore subdirectory directory

So, let's say you have a logs subdirectory in the current directory that you want to ignore:

% svn status
?      logs

Your ignore command would be:

% svn propset svn:ignore logs .
property 'svn:ignore' set on '.'

Now, when you first set this value, you've modified the directory information in the local checkout. You'll need to commit this structure change back into the repository for the changes to be seen in other checkouts:

% svn st
 M     .
% svn ci -m "Ignore the logs subdirectory." .
Sending        .

Committed revision 12207.


As mentioned above, you can also ignore files in and subdirectories of directories beneath the current directory:

% svn st
?      devt/logs
% svn setprop svn:ignore logs devt
property 'svn:ignore' set on 'devt'
% svn st
 M     devt
% svn ci -m "Ignore the logs subdirectory" devt
Sending        inc

Committed revision 12208.

Now when you do a status listing on the local checkout, your ignore files will be properly ignored:

% svn st
%