Ignoring files in subversion

Often you find that you have files that are part of your project that do not belong in version control and you just don’t want to be bugged by subversion highlighting the fact that you haven’t checked them in.

There is documentation on how to ignore these files in the svn book but I found that it lacked a small detail.

Ignoring files globally

There are some files you know that you will never want to check into the repository no matter what project you are working on.  Rather than having to mark them to be ignored in every directory of every project that you store in the repo you can instead set a global ignore.

In your subverison client install directory (for unix operation systems it is probably called .subversion) there is a file called config, scroll down to the section marked global-ignores and set the patterns you wish to ignore

global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
*.rej *~ #*# .#* .*.swp .DS_Store .classpath .settings .project

As you can see, you can use regex to define each pattern. Each pattern is separated by a whitespace.

Setting ignore on a specific directory

N.B. You cannot ignore individual files, you can only set patterns to ignore in a given directory.
First navigate to that directory and issue this command:

svn propedit svn:ignore .

After this you will be presented with a file in which you should type in your pattern(s) to ignore.
It’s pretty simple but I just didn’t spot the fact that you should be putting the patterns in this file rather than specifying the pattern in the svn propedit command itself.

Don’t forget to commit your changes!
Happy ignoring!

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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