Using svn:ignore to ignore everything but certain files

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?*

No, there is no exclusive matching like you described. This article lists the possibilities for pattern matching. It's limited to:

  • ? - Matches any single character
  • * - Matches any string of characters, including the empty string
  • [ - Begins a character class definition terminated by ], used for matching a subset of characters

A similar question was asked already here.


That's the only solution I know of. You can explicitly add files even if they are ignored though.

You would need to add that setting on all subdirectories though.

# Create a repository with property ignore *

[wlynch@orange ~] cd /tmp
[wlynch@orange /tmp] svnadmin create foo
[wlynch@orange /tmp] svn co file:///tmp/foo co
Checked out revision 0.
[wlynch@orange /tmp] cd co
[wlynch@orange co] svn propset svn:ignore \* .
property 'svn:ignore' set on '.'

# Create 3 files

[wlynch@orange co] touch a
[wlynch@orange co] touch b
[wlynch@orange co] touch c

# We can add all 3 of these files in one transaction

[wlynch@orange co] svn status
M     .
[wlynch@orange co] svn add a
A         a
[wlynch@orange co] svn add b
A         b
[wlynch@orange co] svn status
M     .
A      a
A      b
[wlynch@orange co] svn add c
A         c
[wlynch@orange co] svn ci
Sending        .
Adding         a
Adding         b
Adding         c
Transmitting file data ...
Committed revision 1.

Tags:

Svn

Svnignore