Using svn:ignore to ignore everything but certain files

whaley picture whaley · Jul 16, 2009 · Viewed 14.4k times · Source

With the svn:ignore property, is there a way I can specify what I want to ignore based on patterns which I don't want to ignore? In other words, I want to ignore everything but files ending in .xyz. How would I go about doing that (if it's even possible)?

One option I've explored is committing everything I want to be versioned, then setting the svn:ignore property on the directory to be '*', thus meaning no other files but what I've already committed will be versioned. This is the best I can come up with, but it feels dirty in that if I ever did need to add another file to be version, I'd have to make multiple commits... one to remove the svn:ignore property, another to add/commit the new file(s), and then a third to change svn:ignore back to '*'.

Your thoughts?

Answer

tomka picture tomka · Oct 20, 2010

Have a look at Using negative patterns for Subversion's svn:ignore property. Obviously you can use "!" in character groups to negate its meaning. So if you want to ignore everything except files ending with .java, set the following pattern to svn:ignore:

*[!j][!a][!v][!a]
*.java?*