How to delete “.svn” folders
Published on April 15th, 2009Author: Michele
Subversion (svn) stores the state of the working copy in hidden directories called “.svn” which contains SVN metadata. Given a folder wich contains a project checked-out from a Subversion repository (e.g. a directory called “MyProject”), we will have an hidden “.svn” directory for each sub-directory located in “MyProject”. Sometimes there is the need to delete these hidden folders, for example, for sharing the project with people who does not use Subversion, or simply, to archive a copy of the project without SVN metadata.
Deleting manually “.svn” directories from each sub-directory of a project is not an exciting thing, especially if the project is big and if it has a lot of nested directories. To do this task on a Mac or Linux/Unix machine, open your terminal and run the following command in the project directory in which you need to delete the “.svn” directories (e.g. in the “MyProject” directory):
find . -type d -name .svn -depth -exec rm -rf {} \;What this command does is:
“find in this folder (find .) all directories and sub-directories (type -d) called ‘.svn’ (-name .svn) ordering them from parent to children (-depth) and execute (-exec) the command ‘rm -rf’ to the current found directory ({}) and pass ending character to command ‘;’”.
Windows users, instead, can add in the right-click context menu a new option (e.g. called “Delete SVN Folders”) which will run a shell script that will recursively delete all “.svn” folders from the directory in which the script has been run (from: Jon Galloway’s Blog). To do this, it is necessary to copy the following lines of code in a text file with “.reg” extension (e.g. deleteSVN.reg) and then double click on it to install it. This will add new keys in the Windows Registry.
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN] @="Delete SVN Folders" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command] @="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""


Comments (2):
2009-05-01 at 8.59 am
Ho usato proprio adesso questo script. Funziona, grazie!!
2009-05-11 at 8.55 am
Problema appena risolto usando questo script.
Leave a Reply