Easy delete all .svn Subfolders in Windows Explorer
I had to repair a flawed Subversion repository recently (not all files were committed). I had my local repository checked out. This was the flawed part, containing only parts of the folders and files it should.
Then, I got a zip file from the machine where it was working. Problem: It contained .svn folders from the other developer. So to merge these i did the following workflow:
- Delete all .svn folders from other developer’s zip
- Move other developers folder over on top of my local install.
- Commit all missing files
Of course this will only work if there are no .svn folders in other developer’s file, because then svn authentication, paths, etc. will be messed up, and commit will fail.
Luckily, Sanil S (IamTechie blog) wrote a nice little script that actually adds a context menu in Windows explorer:
Just save this file as “delete_svn_subfolders.reg”. When you run it, then you will have the new windows explorer context menu item shown in the image.
The full script (repeated for the ones with javascript disabled:)
Windows Registry Editor Version 5.00 ; ; Running this file will give you an extra context menu item in Windows Explorer ; "Delete SVN folders" ; ; For the selected folder, it will remove all subfolders named ".svn" and their content ; Tip from http://www.iamatechie.com/remove-all-svn-folders-in-windows-xp-vista/ ; ; Enrichened with comments by Jesper Rønn-Jensen ( http://justaddwater.dk/ ) ; ; [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 && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""
More info:
IamTechie: How to remove all “.svn” folders in Windows XP & Vista?
March 7th, 2011 at 19:17 (GMT-1)
Thanks for actually providing the “delete_svn_subfolders.reg” file itself. It’s so nice when someone else has already dealt with the same problem, had done the legwork to fix it, and then provided the solution free of charge to others so we don’t have to reinvent the wheel.. Yes, than you to Sanil S. and to you!
Cheers,
Lois
March 10th, 2011 at 09:27 (GMT-1)
I only delete files using command prompt but it is time consuming and I need to know where is the file situated in the directory. I find your tips on deleting .svn files on Windows operating system easy to follow. I won’t be bothered anymore on locating and typing files on command prompt and deleting it one by one.
April 6th, 2011 at 11:03 (GMT-1)
In Mac OS X you can use the following Bash command:
find . -name .svn -print0 | xargs -0 rm -rf
I have not tried it in Cygwin, but it should work :-)
/Niels Peter
July 28th, 2011 at 05:57 (GMT-1)
Omg this finally solved my problem. I was freaking tired of using the Cmd prompt, this is so much easier. Thanks for the script man, super helpful. By the way I have just upgraded my mac to lion, and I think it’s pretty awesome, I was wondering what you guys thought of it, or are you all windows guys?