How to ignore files and directories in SVN

It is easy to ignore files and directories in Git or Mercurial. Ignore files can be maintained at both the user and repository levels. Git or Mercurial automatically ignore the files and directories that match the patterns listed in these ignore files.

Being a version control system from an older era, Subversion does not have this simple method of ignore.

  • In SVN, ignoring a file or directory is a property that can be set at a specific directory in a repository.

For example, to ignore build subdirectory and *.tmp files:

$ svn propset svn:ignore build .
$ svn propset svn:ignore *.tmp .

Note that both these commands set ignore properties for the current directory .

  • To set an ignore property recursively to all subdirectories in a repository, go to the repository root directory and issue this:
$ svn propset svn:ignore -R *.tmp .
  • Thankfully, you can use an ignore file containing ignore patterns, one per line, as input:
$ svn propset svn:ignore -R -F ~/.svnignore .

Note the difference with Git or Mercurial. You have to manually set this ignore property on every directory. The ignore file we created is for our convenience. If you create a new subdirectory anywhere in this repository, the property needs to be applied again on it.

  • Remember to commit after setting the ignore property.

Tried with: Subversion 1.8.8 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s