Ignoring Files and Directories in Subversion for Easier Linux Server Management

By Juliet Kemp (Send Email)
Posted Mar 8, 2010


There are several ways to ignore files or directories in Subversion so that Subversion will not include them in the output of svn status and will not keep them under version control. However, the exact syntax can be a little tricky.

Tip of the Trade: Finding a way to ignore files or directories in Subversion so they are not included in svn status output is easy; figuring out the exact syntax is not. Here's are way to simplify this Linux server management quagmire.

The single-command version is:

svn propset svn:ignore test .

Note the . at the end to specify the current working directory.

The problem with this approach is it will deal only with a single file. If you run the same command again with a second file:

svn propset svn:ignore test2 .

then test will no longer be ignored (only test2).

There are two solutions to this. The first one is to use svn propset with a text file containing a list of files to be ignored:

svn propset svn:ignore -F ignore.txt .

You'll need to re-read the file whenever it's updated or changed (and the value will be overwritten each time).

The alternative solution is to edit the list of ignores, using this command:

svn propedit svn:ignore .

This will pull up a list of currently-ignored files in your default text editor. Add as many as you like, save the file, and exit. (Note that if you use propset again after this, it will overwrite the values.)

The second point to bear in mind is that when specifying directories, you should not use a trailing slash. This line will work:

svn propset svn:ignore testdir .

But this one will not:

svn propset svn:ignore testdir/ .

Again, of course, you're better off using svn propedit, but the same holds true there. Directory name only, no trailing slash!

All of these solutions are per-directory only; there are other options for global ignores.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).

Follow ServerWatch on Twitter

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.