SUBSCRIBE VIA RSS


Subscribe to our feed

Symfony Experts

Symfony Experts
If you have an urgent question for a symfony-related issue, this is the place to ask.

Topics

TWITTER

Stack Overflow


The old fashioned way

RECENT TUNES

February 17, 2009 – 4:32pm Recursively delete .svn directories

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
Posted in  Web Development   |     |  delicious  Digg

7 Responses to “Recursively delete .svn directories”

  1. You should use:

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

    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

  2. Thanks Jon — I just updated the post to reflect your method.

    By Scott Meves on Feb 17, 2009

  3. You can also use

    rm -rf `find . -type d -name .svn`

    By mikael.randy on Feb 19, 2009

  4. hi,

    You can also use svn export

    export a clean project…

    By nresni on Mar 11, 2009

  5. 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

  6. 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

1 Trackback(s)

  1. Jun 11, 2009: Closer To The Ideal » Blog Archive » Cleanse a directory tree of Subversion

Post a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word