How To Clean Subversion Directories

By Angsuman Chakraborty, Gaea News Network
Thursday, June 15, 2006

When you checkout a repository from subversion it creates a .svn directory (with subdirectories) for every directory (and subdirectory) checked out. The .svn directory contains information about the repository and files in the directory and allows you to run svn commands without having to authenticate yourself in future. However when you want to package the source code it becomes painful to remove them by hand. You can either use a build tool like ant and exclude the .svn directories or you can use my code to clean the directory of .svn junk.

Download SVNClean here.

Usage:
java SVNClean [list of files or directories]

The code runs on any java supported platform (tested on windows and linux).

Use at your own risk. No warranty, implied or otherwise, is provided.

Discussion

rflores
June 4, 2010: 3:16 am

Easier method for GNU/Linux user is to remove all .svn directories with following command:
rm -rf `find ./ -name “.svn”`
And all .svn folder found in current directory are recursively deleted. :)


vidar
October 24, 2008: 1:47 am

To make a java app doing that and then posting about it is the stupidest thing I ever saw. Why not just use find?

April 1, 2008: 7:15 am

Change to root directory folder and type:

find . -type d -name .svn -exec rm {} -R \;

Just for linux! :)


David Mc
August 2, 2007: 1:51 pm

This worked fine for me and was exactly what I wanted. I simply wanted to remove all the Subversion artifacts from a directory structure without having to actually have Subversion loaded or creating a bogus Ant target. This did the trick as expected.

Thanks!


David
March 6, 2007: 11:19 pm

Hm, that nuked my build.xml target tags, try this version…

<target name=”clean-environment” depends=”clean-gen”
description=”Clean all Eclipse/Subversion environment files and directories”>
<delete includeemptydirs=”true” failonerror=”false”>
<fileset dir=”${basedir}” defaultexcludes=”no”>
<include name=”**/.svn/**” />
<include name=”**/.settings/**” />
<include name=”**/.classpath” />
<include name=”**/.project” />
<include name=”**/.tomcatplugin” />
</fileset>
</delete>
</target>


David
March 6, 2007: 11:07 pm

If you prefer an Ant-based solution to deleting hidden/read-only work directories, the ‘defaultexcludes’ option is your friend.


Simo
September 16, 2006: 3:17 pm

That java prog didn’t work for me, and I was too lazy to whip up a script. Neither did that rsync script. So, I created local svn repo and used import/export.

% svnadmin create /tmp
% svn import . file:////tmp
% svn export file:////tmp

June 18, 2006: 12:26 pm

Thanks for the tips.


stand
June 16, 2006: 12:50 pm

Or, if you have rsync you can to this…

rsync -C /path/to/source/ /path/to/dest

The -C option excludes .svn directories on a copy.


Justin Akehurst
June 16, 2006: 11:27 am

’svn export’ is your friend.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :