Ignoring some file in a Subversion working copy
Posted by isilanes on January 3, 2008
Blog moved to: handyfloss.net
Entry available at: http://handyfloss.net/2008.01/ignoring-some-file-in-a-subversion-working-copy/
Sometimes you have files littering a svn working copy, but you don’t want to put them under version management. Often times it is impossible, or plain painful, to delete them, and having them appear in all svn status calls is uncomfortable. This can happen, for example, if you keep a repository of Python files. When a Python script is called from another script (a module, for example), a .pyc file is generated (a “compiled” version of the called .py module, that is just faster to load next time).
Clearly, you don’t want to put the .pyc files in the repository, but deleting them everytime you manage the working copy is painful. For that, you can make svn ignore some files, like e.g. .pyc files. You can do that in at least two ways: specifically for a directory, or as a general preference.
Setting ignore property on a single directory
You can set a property on any directory of a working copy, so that the chosen files in that directory will be ignored by svn. For example:
% svn propset 'svn:ignore' '*.pyc' pythonfiles/
will make svn ignore all .pyc files in the directory “pythonfiles”, but not those in other directories.
Setting ignore patterns globally
You can edit the ~/.subversion/config file, and add “*.pyc” in the line starting with "global-ignores =". For example, my such line is:
global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.pyc *.swp
It works immediately, and for all the calls to svn status you do in any working copy on that machine.