Regular readers may have clocked onto the fact that I use Subversion. Well the way it works it to keep a hidden set of directories within your checked out repository. It uses this to track any changes etc.. Each directory is called ‘.svn’ and is within each and every directory and subdirectory you have.
Now I know I am not alone in saying that when you want to upload the files to a remote server you have to do one of two things
- Upload the files and .svn directories to your server which is likely to take twice the time and twice the disk space
- Make a separate local copy of your files and then remove the .svn directories one by one.
I prefer to take option two although in recent months I have taken on the former through sheer laziness. I decided to look for a solution and found my answer…
For windows machines you need to create a secondary copy of your files to upload, this means it won’t wipe out your local repository files (the ones you want to keep). Next, create a ‘.bat’ file (batch file for executable scripts). The simplest way to do this is to open notepad and doing File > Save as > remove_svn.bat after copying in the code below. It needs to be saved in the root directory of your repository copy. This is important if not it will recurse all directories below the one it is placed in.
for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do ( rd /s /q "%%i" )
I have done all the hard work for you on this one.
Just click the following link:
For Macs and other Unix based machines you need to do something similar. This time we simply run a command on the shell (or create a shell script out of it). Again this must be placed in the directory you want to recurse through.
find . -name .svn -print0 | xargs -0 rm -rf
Credit for these snippets goes to the following sites. Whether they were the original authors or not I don’t know but credit where credit is due etc..
Mac version – http://snipplr.com/view/201/remove-all-svn-directories/
Windows Version – http://bluespark.tumblr.com/post/23853870/remove-svn-subfolders-on-windows-xp-vista