One is really not very interested in being reminded of the existence of this digital rubble in the output of
svn status
. Therefore, there are various ways of telling Subversion to “ignore” certain files based on the pattern of their name.That takes care of the output of
svn status
, but not of ls
(which is still cluttered), nor your disk space. So what's a quick way of getting rid of those files?It's easy:
svn status | grep ^? | awk '{print $2}' | xargs rm -rf
or, if you wish to also delete those files which are ignored by Subversion,svn status --no-ignore | grep ^[?I] | awk '{print $2}' | xargs rm -rf
Note that this second version could be useful if make clean
(or equivalent) is not quite as thorough as you'd like it to be.And that's really all there is to it. But just because I like to make things complicated, I've wrapped up this idea in a little script – svnclean:
$ svnclean --help
usage: /home/carlo/bin/svnclean [-i] [-f] [-q] [-h|-?|--help]
Recursively cleans the current svn working copy starting from the current
directory. It does this by inspecting the output of `svn status'. Options:
-i Also remove files ignored by SVN (e.g. via svn:ignore properties)
-f Do not confirm deletion
-q Do not list every file before deletion, only print number of affected
files
-h, -?, --help This help
$ svnclean -i
Files/directories to be deleted:
awesomez.pyo
tmp_experiment/
ai.o
ex
Continue? [yn]