svn:ignore

I found out about svn:ignore recently, and thought that I would share. The doc is here: http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.advanced.props.special.ignore

Basically, you go into the directory that you want to set up with ignores. This would be a pattern of filenames that you don’t want to ever check into svn, you want svn to ignore them. You can do this recursively by using the -R switch.

svn propedit svn:ignore . #Set up an ignores file in this directory
svn -R propset svn:ignore -F svnignores.txt . #Copy the svnignores.txt file into the svn:ignores information for this directory and all contained directories recursively


Just list out what you want svn to ignore, one pattern on each line. * is wildcard.

My svn:ignore files tend to look like this:

*.pyc
*~
#*#

So, I'm ignoring compiled Python files with *.pyc, Emacs backup files with *~, and vi backup files with #*#. You can add in any other patterns you like, such as bin and eggs directories.

~ by Liz on April 16, 2008.

14 Responses to “svn:ignore”

  1. I heard keeping up svn:ignore can be a real PITA, so I’ve settled on just setting up global ignores in my working environment. See http://www.unc.edu/~jj/plone/ for details, including making it work in windows (no menu on my site just yet, grep for ‘Import Into Subversion’ and look at step #8)
    Edit: That’s step 8

  2. Jjmojojjmojo: There are pros and cons to each method. I like svn:ignores because it keeps users that might not have their svn set up to ignore these files from checking them in. It is a pain, though, I admit.

    If you’re just working on your own stuff, or have all the developers use the same global configuration method, the global ignores is a very nice solution, much easier to keep up.

  3. So, I said:

    svn propedit svn:ignore .

    and entered some ignore patterns in the text file that automatically pops up (called svn-prop.tmp by default) and saved it, and nothing seems to have changed in the svn status — files are still marked with “A”. is there something else I need to do? Thanks.

  4. Andy:

    Are the files that you wanted to ignore in the same directory in which you ran this command? Use the -R switch to make this work in subdirectories: svn propedit -R svn:ignore .

  5. Hmm, when I do that command I get

    “Subcommand ‘propedit’ doesn’t accept option ‘-R [–recursive]'”

  6. for -F you would use svn propset (use the file specified as the value to set the property to). For recursive, you would also need to use propset. So, e.g.,

    svn -R -F [apply_this_file_everywhere] propset svn:ignore .

    would set the svn:ignore property to the values in the file you provide to all directories under the current working directory.

    You should be careful about this though. Any directories that already have svn:ignore set will have those settings completely overwritten. So it’s best to use this when setting up a project, or on a subdirectory that has no svn:ignore settings at all recursively. I’m sure there’s some way (on Linux or *nixen) to write scripts that will edit/add patterns recursively, but I don’t need that yet, so haven’t spent any time at it yet :-).

  7. Awww…
    Subcommand ‘propedit’ doesn’t accept option ‘-R [–recursive]’

  8. Oop, sorry, my mistake.

    The recursive command works with propset, not propedit. I’ve edited the post to reflect this.

  9. @andy
    Make sure there aren’t any spaces in the file when you use propedit.

  10. Thanks so much for this post! I knew there had to be a way to do this, but didn’t think about the propset command.

  11. Awesome, your recursive option note saved me some time.

  12. […] For our situation, however, we need to ignore .LCK files for ALL directories within /html. Running the previous command in each directory is possible, but not very efficient. So I did some searching and found the solution here: https://athenageek.wordpress.com/2008/04/16/svnignore/ […]

  13. your font is too small

Leave a comment