Ignoring Directories and their Contents in SVN
Ignoring A Directory
Sometimes you want to be able to set a property in order to ask SVN to ignore a given directory and its contents - such as log directory or temporary files in an application.
In the following example, we want to ignore the temp directory and its contents - although temp exists in our local copy, it has not yet been added to (and therefore created in) the repository:
foo/ foo/html/ foo/html/index.php foo/pictures/ foo/pictures/me.jpg foo/pictures/dog.jpg foo/temp/ foo/temp/note1.txt foo/temp/note2.txt foo/temp/bar/ foo/stuff/ foo/stuff/cactus.gif
Firstly we need to add the directory to be ignored to the repository, but not its contents. By default SVN adds files and directories recursively, so to get round this we use the non-recursive switch.
[foo/]$ svn add --non-recursive temp [RET] A temp
How do we now get SVN to ignore the temp directory?
Simple! Just set a property on that directory of svn:ignore
[foo/]$ svn propset svn:ignore ADD temp [RET] property 'svn:ignore' set on 'temp'
Once you commit this change, an update or commit is command will ask SVN to ignore the temp directory.
Ignoring the Contents of an Ignored Directory
Some time later, you run the svn status command, and you keep getting the following:
M foo/html/index.php - This file has been modified ? foo/temp/note1.txt - This file is unknown to SVN ? foo/temp/note2.txt - This file is unknown to SVN ? foo/temp/bar - This directory is unknown to SVN
How do we stop seeing this guff each time we run an svn status command - after all, its coming from an ignored directory!
Once again the solution is pretty simple - go into the directory we set to ignore earlier on:
[foo/temp/]$ svn propset svn:ignore "*" . [RET] property 'svn:ignore' set on '.'
And then commit the property change to the repository. The next time we run svn status we get:
M foo/html/index.php - This file has been modified
Hooray!
About this entry
You’re currently reading “ Ignoring Directories and their Contents in SVN ,” an entry on chris ramsay
- Published:
- 5.21.07 / 12pm
- Category:
- Programming, Subversion










No comments
Jump to comment form | comments rss [?] | trackback uri [?]