Recursively remove .svn directories

find . -type d -name .svn -delete

4
2010-03-01 18:48:31

5 Alternatives + Submit Alt

What Others Think

It took 6 times to get this simple command right? And i hate to break it to you, but you should be using "svn export" anyway, especially since you're likely to have your working copy in some special location for working copies only
rkulla · 429 weeks and 6 days ago
No idea what gt3 is trying to say, but... Downvoting this because it does not work. The -delete option won't remove nonempty directories, at least on my system. and .svn directories will always be nonempty. You could try to contort find to your will, but -prune won't work with -delete. You have to do something like the solution by nishan_n (#4917).
bwoodacre · 429 weeks and 6 days ago
bwoodacre, if you click the title of the cmomand 'Recursively remove .svn directories' there's 5 previous attempts by other people to do this command on commandlinefu.com. That's what I meant by "it took 6 times". However, you're correct, this command is wrong and will report "Directory not empty". I should have said that nishan_n had it closer but i still think people should just use 'svn export' if they want to get rid of the .svn directories safely.
rkulla · 429 weeks and 5 days ago
You are right, the suggestion to use svn export is easier and less error-prone if you just want a .svn-free version of a particular chunk of a *repository*. But that doesn't handle any differences that your working copy has: unversioned files that you want to keep around, or checked-in files with changes that you don't want committed.
bwoodacre · 429 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: