Cleaning Up After SVN

If you’re using SVN for keeping your source safe for web apps, you may notice uploading the working folder also uploads all those hidden .svn folders. Not ideal.

Here’s the shell command to delete all those .svn files from your working directory:

find -d "your/working/directory" -name ".svn" -exec rm -r '{}' ; -print

The -d flag (-depth) means the find command will “process each directory’s contents before the directory itself” so the rm (delete) command won’t complain it can’t find a file in the structure it just deleted.

(I am not responsible if this screws up your project, I assume if you’re a developer and you’re using SVN you should know what you’re doing. However, just in case you don’t, once you run this command you won’t be able to update your working copy, nor commit or anything else, so… [insert cautionary advice here])

  • twa

    These files only exist when doing a “checkout”. If you do an “export” these files are removed.

  • http://zynode.info/ jim

    yeah, or rather, export, as its name proclaims, exports the files of the project just… while the checkout feature is meant to create a local working directory which can be updated if the repository is updated, or changes can be committed to the repository…

    of course, people familiar with svn should already know this… lol

    but yeah, it can be useful to remove all .svn folders in a flash if you need archive your project for distrobution, and don’t wanna export all the files outta svn,.. also like sxtxixtxcxh mentions, when uploading your web-based apps to the production server…

    my approach to it tho would be to create a tag in the repository called production, login then ssh/telnet into the production server, and simply checkout a copy of http://domain/svn/project/tags/production/ for example, into the sites root, or wherever the script lives on the server. then obviously configure apache to block access if any .svn folders are requested. then i’d create a php script which requires me to authenticate, which can execute svn update on the scripts working directory, then i’d just have to copy /trunk to /tags/production and run the php update script (or login via ssh) whenever /trunk is in a production stable form. :)

    thats my web-development and deployment plans, which i’ll be implementing soon together with sxtxixtxcxh on his lib.rario.us project. one of us will blog about the details with working code and configuration options once we’re done ;)

  • Pingback: prototypecreative.com » SVN Cleanup Crew