Ubuntu Server: Recursively Remove .svn Folders Tips, Tricks and Tutorials 17 FEB 2014

ubuntu-10-logoSometimes SVN repositories just go bad and the best way forward as far as what you are concerned is to simply wipe them and start out fresh. Of course, while you can simply delete the SVN repo directly to remove it and then quickly recreate it with a few commands, you obviously need to tread a little more carefully around your existing SVN checkout – basically the collection of folders and files that you’re going to be using to repopulate your shiny new SVN repository with!

If you forgot to export your current checkout before deleting your SVN repo or perhaps the repository was too damaged to allow for exporting, you now sit with the situation where your checked out folders and subfolders all contain the obligatory hidden .svn directory which Subversion uses to store its required metadata in.

So in order to continue, we need a method of recursively removing these .svn hidden folders.

Luckily, by chaining the Linux find command with the suitable remove command, achieving this is pretty damn quick.

First, scope out just what files are going to be affected by the recursive delete function by first rather echoing out a list of affected folders/files:

find . -name .svn -exec echo {} \;

If you are happy with the list, continue with the actual delete:

find . -name .svn -exec rm -rf {} \;

Done. Of course, it’s best not to be messing around with SVN repositories in this fashion, but like most bad options in life, sometimes it is just completely unavoidable.

Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.