How To Delete .svn Folders From Your Project (on Windows, Linux and Mac)

I am currently working on developing a WordPress plugin, and I use svn for version control. If you have ever used subversion to manage your projects, then you probably already know that there are many (hidden) .svn folders in the checked out project. These folders are created by subversion clients (like TortoiseSVN) to store information about the project’s local state.

The .svn folders are important for the subversion clients but it gets really annoying when sharing the source with someone or uploading it on web. These folders create unnecessary bloat. Its also very difficult to delete all the .svn folders one by one since there are too many of them. Here’s the procedure to delete all .svn folders automatically on Windows, Linux and Mac.

Delete All .svn Folders From Your Project on Windows XP, Vista and 7

1. Create a file cleanSVN.reg with the following registry commands,

Windows Registry Editor Version 5.00
@="Delete SVN Folders"
@="cmd.exe /c "TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r "%1" %%f IN (.svn _svn) DO RD /s /q "%%f" ""

2. Double click on cleanSVN.reg to run it.

This will add a new option, Delete SVN Folders, in your right click context menu.

Just right click on your project folder and select this option to remove all .svn folders instantly. It works perfectly on Windows XP, Vista and Windows 7.

Delete All .svn Folders From Your Project on Linux and Mac

If you are on Linux or Mac, then open terminal and go to your project directory. Then use this command to remove all .svn directories.

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

Please don’t run this command as root. In fact, you should not run any command as root :)

Note 1 – As I mentioned above, .svn folders are used by subversion clients to manage your project. If you delete those folders, the subversion client will forget everything about your project. So, I advise you to make another copy of your working copy at a different location and then clean it.

Note 2 – You can use the svn export command to directly get a clean copy (a copy without .svn folders).

Note 3 – If you use the TortoiseSVN subversion client, then just export to the current working copy location and it will automatically remove the .svn folders and files(ref).