Remove hidden .svn directories with a simple Unix command

When Working Copies are checked out of a Subversion repository, Subversion creates a hidden “.svn” directory in each directory of the Working Copy to store metadata about your project and any changes you’ve made.

This metadata increases the total size on disk of your Working Copy, so if you need to send a copy of your project to someone you can remove the metadata by opening a Terminal window, navigating to the top-level directory of the Working Copy, and running this command:

sudo find * -type d -name .svn -exec rm -rf {} \;

In the command above, the “-type d” argument specifies that the find utility should only search for directories, the “-name .svn” argument specifies that it should search for results with “.svn” as their name, and the “-exec rm -rf {} \;” argument specifies that it should execute “rm -rf” (remove recursively without asking for permission on individual files) on the results.

Please note that after you’ve run this command on a Working Copy’s directories, you won’t be able to use any svn commands (e.g. “svn status“, “svn update“, “svn commit“, etc.) on it anymore.

 

Related posts:

  1. Checking directory sizes on a Bash command line
  2. Showing hidden files and directories in the Finder in Mac OS X
  3. Finding text within specific types of files from the command line
  4. List comments and files changed for a specific Subversion Revision
  5. Mac OS X Quick Tip: Using Spotlight to search from the command line
Twitter Digg Delicious Stumbleupon Technorati Facebook Email

4 Responses to “Remove hidden .svn directories with a simple Unix command”

  1. Or you could use the svn export command.

    svn export /path/to/repo /path/to/unversioned/copy

  2. Brilliant, thanks Keegan!

  3. It works great!!!

    the ways are usefull for me! thanks

  4. Using the ‘find’ method is great when you have a local working copy using svn and want to change to another vcs without moving directories.

Afrigator