Recursively Remove .svn Directories in Linux

Recursively Remove .svn Directories in Linux

Subversion is a pain, but without it things can be even worse. Sometimes your workstation will get out of sync with the server or if you're like me you realize that you accidentally FTP'd the entire project directory to the web server including all the hidden subdirectories and don't want that floating around online.

Another mistake I commonly make is using the copy feature to copy a series of directories in Eclipse from one project to another. Unfortunately Eclipse will invariably copy all the Subversion pointers as well, completely breaking the target project's SVN links. In that case, I take the hosed project, move it out of Eclipse entirely, check out the current committed copy, then move all the project files back into place, replacing the just checked out copy - to do this you must first delete all the .svn directories.

There's a quick an easy fix using the console to remove all the .svn directories.

rm -rf `find . -type d -name .svn`
Tada! One line takes care of it all for you, recursively. I don't do a lot of coding anymore, but for most larger projects I will create a basic framework before I hand it off to the developers assigned to the project. This ensures that everything stays per my coding standards and helps me keep an eye on development since I'm not having to learn a completely different layout. I regularly check the current Subversion editions of all projects we have going.
Posted by Tony on Jan 26, 2009 | Desktop Linux