svn:ignore propset

SVN users who wish to ignore multiple files with distinct names in the same folder beware : you must use a file and batch-process.

It’s not difficult to figure out that to tell SVN to ignore a file, you use:

svn propset svn:ignore [filename] [folder]

So if I have a file ‘config.php’ in folder config, in the config folder I would simply type

svn propset svn:ignore config.php .

But what if I also have another file, say ‘database.php’, in the same folder that I want to ignore?  On top of that, what if I have other files with a .php extension that I don’t want to ignore?  The following will not work:

svn propset svn:ignore “config.php database.php” .

(incorrect syntax)

svn propset svn:ignore “*.php” .

(but i don’t want to ignore some .php files)

nor would the following, because svn for some odd reason seems to only take one propset assignment from the commandline – meaning only one of the files will be ignored:

svn propset svn:ignore config.php .
svn propset svn:ignore database.php .

turns out you must make a file with the filenames on separate lines, then call with the -F parameter.  For example in the above case, I would create a file “ignore.me” with config.php and database.php on separate lines, then call

svn propset svn:ignore -F ignore.me .

Annoying.  SVN should let you set the same property on multiple files with multiple command-line calls.

Digg! delicious
Posted on Sunday, June 10th, 2007 at 4:04 pm and filed under geekery. Subscribe to RSS 2.0. Leave a comment or trackback.

8 Responses to “svn:ignore propset”

  1. Alex Egg

    Thank you for this. This was not very intuitive at all! No mention of this in the svn book that I could find…

  2. Massimo32

    You can insert multiple lines from the commandline, just press enter inside the quotes:

    $ svn propset svn:ignore ‘config.php [enter]
    > database.php’ . [enter]

  3. mregamr

    Massimo32, this was the key I was looking for…how to add a newline in between arguments.

    Thanks!!

  4. JN2

    You can also try this in a shell script called with a space separated single quoted list, eg ‘qwe.txt asd.pid’:

    svn propset svn:ignore “`echo “$1″ | tr ‘ ‘ ‘\n’`” .

  5. Howard

    It seems that using \n to embed a newline character in the property string should work to set svn:ignore to multiple files, but it does not.

  6. john campbell

    Don’t bother with propset… use propedit

    svn propedit svn:ignore .

    will bring up your editor, and you can add the rules directly.

    It also avoid the potential confusion caused by expansion of ‘*’

  7. Lukas Zapletal

    Good trick the one with -F. Thanks :-D

  8. Sascha W.

    John’s solution seems to be the best one.
    Thanks to all.

Leave a Reply