views:

28591

answers:

13

Just started using SVN and I have a cache directory that I don't need under source control. How can I ignore the whole directory/folder with SVN?

Edit: Using Versions and TextMate on OSX and commandline

+44  A: 

Set the svn:ignore property of the directory:

svn propset svn:ignore dirname .

If you have multiple things to ignore, separate by newlines in the property value. In that case it's easier to edit the property value using an external editor:

svn propedit svn:ignore .
Jason Cohen
... using the "svn propedit" command.
Blair Conrad
It doesn't work as expected.tipi:/var/www/tipi# svn commit -m "More accents" *svn: '/var/www/tipi/tmp' is not a working copysvn: Can't open file '/var/www/tipi/tmp/.svn/entries': No such file or directorytipi:/var/www/tipi# svn propset svn:ignore tmp .property 'svn:ignore' set on '.'tipi:/var/www/tipi# svn commit -m "More accents" *svn: '/var/www/tipi/tmp' is not a working copysvn: Can't open file '/var/www/tipi/tmp/.svn/entries': No such file or directory
Kouber Saparev
A: 

Set the svn:ignore property. Most UI svn tools have a way to do this as well as the command line discussion in the link.

Joe Skora
+9  A: 

To expand slightly, if you're doing this with the svn command-line tool, you want to type:

svn propedit svn:ignore path/to/dir

which will open your text-editor of choice, then type '*' to ignore everything inside it, and save+quit - this will include the directory itself in svn, but ignore all the files inside it, to ignore the directory, use the path of the parent, and then type the name of the directory in the file. After saving, run an update ('svn up'), and then check in the appropriate path.

Greg
Very good point, thank you. All other answers missed case of nested directories. So the above example (working) you then type in editor ignored_directory (which is by assumption one level below path/to/dir). This won't work though:svn propedit svn:ignore .and then typing path/to/dir/ignored_directory in editor.IOW: SVN matches objects one level down at a time.
macias
A: 

If you are using a frontend for SVN like TortoiseSVN, or some sort of IDE integration, there should also be an ignore option in the same menu are as the commit/add operation.

Chris Marasti-Georg
+4  A: 

Gilean, are you using a particular SVN client (i.e. tortoise)? In the tortoise client, on commit, you have the option of right clicking items and selecting "Add to ignore list". The answer here depends on how you access your SVN repository.

Michael Lang
+1  A: 

If your project directory is named /Project, and your cache directory is named /Project/Cache, then you need to set a subversion property on /Project. The property name should be "svn:ignore" and the property value should be "Cache".

Refer to this page in the Subversion manual for more on properties.

The Digital Gabeg
A: 

Jason's answer will do the trick. However, instead of setting svn:ignore to "." on the cache directory, you may want to include "cache" in the parent directory's svn:ignore property, in case the cache directory is not always present. I do this on a number of "throwaway" folders.

harpo
+4  A: 

Set the svn:ignore property on the parent directory:

$ cd parentdir
$ svn ps svn:ignore . 'cachedir'

This will overwrite any current value of svn:ignore. You an edit the value with:

$ svn pe svn:ignore .

Which will open your editor. You can add multiple patterns, one per line.

You can view the current value with:

$ svn pg svn:ignore .

If you are using a GUI there should be a menu option to do this.

Frank Szczerba
+47  A: 

here's an example directory structure:

\project
    \source
    \cache
    \other

when in project you see that your cache dir is not added and shows up as such

> svn st
M  source
?  cache

to set the ignore property

> svn propset svn:ignore cache .

where svn:ignore is the name of the property you're setting, cache is the value of the property, and . is the directory you're setting this property on. It should be the parent directory of the cache directory that needs the property.

to check what properties are set

> svn proplist
Properties on '.':
  svn:ignore

to see the value of svn:ignore

> svn propget svn:ignore
cache
craigb
And to undo this?
Nathan Long
I appreciated the description of what each of the parameters stood for.
DonnaLea
I agree with DonnaLea. Great answer, thanks.
danilo
@Nathan `pdel svn:ignore` or just `pset svn:ignore "whatever other dirs to ignore"`
knoopx
+16  A: 

Important to mention:

On the Commandline you can't use

svn add *

this will also add the ignored files, because the Commandline expands * and though, each file is given on the Commandline. svn add believes that you would explicitly add those file. Therefore use

svn add --force .
binco
+1 for mentioning this subtle point often the source of many headaches.
mike
+9  A: 

Since I spent a while trying to get this to work, it should be noted that if the files already exist in svn, you need to svn delete them, and then edit the svn:ignore property.

I know that seems obvious, but they kept showing up as ? in my svn status list, when I thought it would just ignore them locally.

Kai
OMG so this is what was happening to me and driving me mad... Thanks
nabucosound
A: 

hi, how do i ignore a specific directory during runtime.

say checkout is

test->dirs->dir1 ->dir2 ->dir3

now i want to checkout and I want to ignore directory dir3 which is insie dir, during runtime of checkout

souri
This should be a new question. There is no way to ignore a folder if it is under source control.
Lee
A: 

I had problems getting nested directories to be ignored; the top directory I wanted to ignore wouldn't show with 'svn status' but all the subdirs did. This is probably self-evident to everyone else, but I thought I'd share it: EXAMPLE: /trunk /trunk/cache /trunk/cache/subdir1 /trunk/cache/subdir2

cd /trunk svn ps svn:ignore . /cache cd /trunk/cache svn ps svn:ignore . * svn ci

brainycat