Remove all .svn directoriesRemove all .svn directories

Posted March 11th, 2011 in Linux/Unix/BSD

If you've been using Subversion for revision control and no longer want to use it (for example if you've moved to another revision system like git) there are a whole bunch of .svn directories you'll need to get rid of. This post shows how to remove them from the command line on Unix based systems like Linux and Mac OSX.

find with -delete

This is a nice simple solution that works on Linux but doesn't work on my Mac. It works fine for filenames that don't start with . so I suspect that's the issue. Change to the directory you want to delete the .svn directories from and run this command:

find . -name .svn -delete

find with -exec

This is a slightly more complex command but it will work on both Mac and Linux:

find . -depth -name .svn -exec rm -fr {} \;

The -depth argument is required to prevent find entering the directory that was just deleted and showing error messages like e.g. "find: ./.svn: No such file or directory"

The -exec part runs rm -fr passing the name of the file/directory found where the {} placeholder is. The \; at end terminates the exec command and \ is required to escape it on the command line.

Related posts:

Comments

blog comments powered by Disqus