SVN Ignore Files or Directory

This is a small command that will ignore some files or directory in SVN. Ignoring files is useful when there are files that are not actually needed by your project but it just get in there like temporary files, cache files and log files. You may also need to ignore files that are created by the operating system or some programs.

For example, you wanted to ignore the annoying Thumbs.db in Windows. Thumbs.db usually appears on a directory when it is viewed in Thumbnail view. To ignore Thumbs.db in project/images, here are the possible commands:

cd project/images
svn propedit svn:ignore Thumbs.db .

First, we change current directory to the images directory. Next, we ignore the file Thumbs.db and set that property to “.”, which means the current directory. If that gives you error that says that Thumbs.db is not a working copy sort of, change the command into this:

svn propset svn:ignore Thumbs.db .

The above command will ignore that file which is not yet added to the repository. If you wanted to ignore a directory, the command is the same as ignoring files.

Another classic example is to ignore files inside the templates_c directory used by Smaty template cache. Here is it (be sure to change into the templates_c directory):

svn propset svn:ignore *.php .
svn commit -m "Ignored smarty cache"

Or you can use propedit just in case you have already added them to the repository. If you are using a GUI based SVN client, it is much easier.

This entry was posted in SVN and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *