Recursively remove .svn files
December 16th, 2005
Here’s a quick shell script to recursively remove all the the .svn files starting in the current directory and working down.
find . -type f -name "*.svn" -exec rm '{}' \; -print
Change .svn to look for different types.
Mike Says:
September 7th, 2007 at 12:39 am
This creates a “Run Shell Script” that never goes away in my title bar…
Are you sure this is doesn’t end up looping?
Hardwarerocks Says:
September 18th, 2007 at 1:45 pm
The code above will not work.. Error.. warning: the -d option is deprecated; please use -depth instead, because the latter is a POSIX-compliant feature.
This one works.. find . -type f -name “*.svn” -exec rm ‘{}’ \; -print
Simon Says:
December 11th, 2007 at 10:16 am
Mike – not sure how you’ve run the script but it’s always been fine for me. Have you any other details.
Hardwarerocks – Thanks for the info, the man page for find on my install (OS X Tiger) doesn’t mention that -d is deprectated. However I’ve changed the post accordingly.
David Says:
February 21st, 2008 at 10:48 am
The .svn ‘files’ in question are folders which contain the subversion meta-data, including the pristine copies of the checked-out files of your working tree; deleting them means the tree can’t be used as a subversion working tree.
I’m puzzled that you would want to treat an svn working tree this way, unless you specifically want a checked-out copy of the repository without the .svn folders. That’s what ‘svn export’ is for.
Akshay Surve Says:
February 23rd, 2008 at 2:47 pm
The semicolon afer .svn is missing.
Simon Says:
September 28th, 2008 at 2:35 pm
@ David
I understand where you’re coming from and if you use subversion correctly there should never be a need to remove the hidden svn files. However, from time to time, I do find that it’s necessary – generally when someone has mistakenly duplicated directories using the Finder in OSX.
Bob Says:
July 10th, 2009 at 4:28 pm
With the slightest of tweaks, this was actually useful to me. Sometimes svn crashes and leaves your working copy ‘locked’. Changing the cmd-line to:
find -type f -name “lock” -exec rm ‘{}’ \; -print
…enabled me to quickly get rid of all those pesky lock files.
Just make sure there’s no real content called “lock” ;)
Mahbub Says:
May 25th, 2010 at 4:08 am
How about
rm -rf
find . -type d -name .svnIt works for me :)