If you use Subversion to manage your projects you probably have noticed hidden .svn folders in your checked out projects. A Subversion client creates them to store any information about the project’s local state. It’s not a problem until you need to publish your project on the server or share it somewhere.
Why copy unnecessary .svn folders on the server? They can contain lots of data that you do not need and the project will be a bigger size. Of course you can use file manager and remove them all manually, but there is a better idea…
If you are a windows user there is a very nice solution that I found on Jon Galloway’s blog:
- Create a file with .reg extension and the following content (or download one that I’ve created):
[HKEY_LOCAL_MACHINESOFTWAREClassesFoldershellDeleteSVN] @="Delete SVN Folders" [HKEY_LOCAL_MACHINESOFTWAREClassesFoldershellDeleteSVNcommand] @="cmd.exe /c "TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r "%1" %%f IN (.svn) DO RD /s /q "%%f" ""
- Run the file in the previous step. It will add “Delete SVN Folder” in context menu for all folders.
For Mac users there are powerful bash scripts. We will create one for this purpose.
- Create file “remove_svn” in /usr/bin with the following content:
#!/bin/sh echo "Remove SVN folders from" rm Ã¢â‚¬â€œrf `find . Ã¢â‚¬â€œtype d Ã¢â‚¬â€œname .svn`
- Change permissions to allow other users to execute it:
chmod 755 /usr/bin/remove_svn
- Change the current directory to the project you want to clean:
- Run command:
Please notice that these actions will remove information that the Subversion client needs to manage your project. So do not do it with a working copy. To get a clean copy you need to copy the project folder to another location and clean it there.
And finally, there is a second method to get a clean copy of your project Ã¢â‚¬â€œ using “svn export” command. More details about it you can find in the book Version Control with Subversion.