Three Ways to Recurrently Delete .svn in Windows


If you have ever used SVN (Subversion) as a source control you will know that it will create .svn directory in every sub-folders to keep a shadow copy of the original source. This .svn directory is hidden by default, but could occupy a large chuck of space depends on how large your file and how many nested directories in your project. The .svn folder in each of the directories are by design since svn can be used both as a local repository and a centralized repository. The trouble is when there are large number of nested sub-folders with all the .svn directories to have a clean version of the entire project is troublesome.

Method One – Use SVN build-in command

If you are able to access the original SVN repository the best practices is to use the following command to export a clean version of directory without .svn folders.
svn export

However if you lost access to the original repository or only a partial directories that were tracked by SVN this build-in command will not work for you.

Method two – Use PowerShell To Cleanup

You can always fire up Windows PowerShell to help you find all the .svn folders recursively and delete them from any parent folder.

gci -fil '.svn' -r -force | ri -r -force

If you run this command inside Windows PowerShell from the parent directory of your SVN project. This command will recursively delete all the .svn directories, or any other hidden folders, just update the ‘.svn’ to your need. A very handy command to keep around. For more details on gci Windows PowerShell see TechNet documentation here, gci stands for Get-ChildItem.

Method Three – Windows Registry Batch Add-on

This is arguably the best method for none techies. All you need to do is download this Windows Registry here and double-click to install. It will add a new right-click menu called “Delete SVN Folders“.2015 03 23 1514 600x409 - Three Ways to Recurrently Delete .svn in Windows

By selecting “Delete SVN Folders” it will recursively delete all the child folder .svn in Windows command prompt. You can find the source code for the batch script here from Github.


Please enter your comment!
Please enter your name here