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

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 by in  Web Development   |  

7 Responses to Recursively delete .svn directories

  1. Jon Williams says:

    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.

  2. Scott Meves says:

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

  3. mikael.randy says:

    You can also use

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

  4. nresni says:

    hi,

    You can also use svn export

    export a clean project…

  5. sqz says:

    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

  6. Pingback: Closer To The Ideal » Blog Archive » Cleanse a directory tree of Subversion

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