This came in handy today when I copied a directory from another project and didn’t recognize that it was under version control in that project. Needless to say, my current project got very confused during an svn commit when it encountered this copied directory. To reconcile the situation, I had to recursively delete all of the .svn directories from the copied directory, and then check it in as a fresh copy to the new project.
find . -type d -name .svn -exec rm -rf {} \;
Update 1: Thanks to Jon for this improved method!
Update 2: I have this in my notes too, but I don’t know enough about the shell to know which is better.
find . -iname '.svn' -print0 | xargs -0 rm -rf




You should use:
instead. This approach doesn’t escape spaces in file names which would cause problems if you had a directory with a space in it.
By Jon Williams on Feb 17, 2009
Thanks Jon — I just updated the post to reflect your method.
By Scott Meves on Feb 17, 2009
You can also use
rm -rf `find . -type d -name .svn`
By mikael.randy on Feb 19, 2009
hi,
You can also use svn export
export a clean project…
By nresni on Mar 11, 2009
I always forget these smart oneliners, I always end up with :
rm -rf */.svn
rm -rf */*/.svn
rm -rf */*/*/.svn
also works like a dog
maybe one should make an alias for the smart oneliner
By sqz on Mar 24, 2009
Thanks again for this tip. One thing to note: for me, this ran into problems with directories:
find . -type d -name .svn -exec rm {} \;
I got “.svn is a directory” errors.
I had to add the rf flags:
find . -type d -name .svn -exec rm -rf {} \;
That worked for me.
By Lawrence Krubner on Jun 15, 2009