Unix Command To Remove Subversion .svn Directories

13 Oct 2005

Today I wanted to grab the latest revision of Model Glue in hopes of checking out something which is fairly intriguing to me, Coldspring integration. I'm unable to do this from my workstation, so I SSH'ed to my FreeBSD box at home (the server which you're reading this page from) to grab it via the Subversion command line client.

One annoying thing about doing a checkout of a Subversion branch is that it also grabs all of the .svn directories which contain the history of changes. This is fine if you plan on committing changes to the code base, but not if you just want a working copy of it. These directories can get quite large and take up an incredible percentage more space than the code. To get rid of these directories before SCP'ing the code to my workstation, I used this command to clean out all of those directories (from the root directory where I pulled down the code):

find . -type d -name '.svn' -print0 | xargs -0 rm -rdf

This cleaned out all of the cruft that I didn't need, and I was able to grab it without needing to gzip it first. Hopefully this helps someone else faced with a similar problem.

Update: Even though the same thing can be done with an svn checkout command, this command is still very useful when you've created new code and added it to svn, but then refactor/move it before you check it in. You can delete all of the .svn files and directories, and then add the directories/files back into subversion again without it getting angry at you.