views:

461

answers:

5

If I have a working copy of a Subversion repository, is there a way to delete all unversioned or ignored files in that working copy with a single command or tool? Essentially, I'm looking for the SVN analogue to git clean.

Either a command line or GUI solution (for TortoiseSVN) would be acceptable.

A: 

This oneliner might help you:

$ svn status | grep '^?' | awk '{print $2}' | xargs rm -rf

Use with care!

jkramer
A: 

Hi, you can't delete them with just SVN command line (not sure about GUI tools though) if you are under linux system this might help:

http://www.guyrutenberg.com/2008/01/18/delete-unversioned-files-under-svn/

The other (brutal) method is to commit changes, delete all from folder and checkout again.

Juriy
A: 

This is similar to other answers, but actually gets ignored files (note the 'I' in the REs):

 rm -rf `svn status --no-ignore | grep '^[\?I]' | sed 's/^[\?I]//'`
pkh
+3  A: 

Using TortoiseSVN:

  1. Right-Click on the root of the working copy and select TortoiseSVN -> "check for modifications"
  2. Select "Show ignored files"
  3. Sort by "Text status" column
  4. scroll to the "non-versioned" files, now all grouped together; select them all and right-click -> delete
  5. scroll to the "ignored" files, now all grouped together; select them all and right-click -> delete

Not really a nice and clean solution, but the fastest way I know of (on Windows).

Thanks to pkh for the tip with the ignored files.

Thomas Lötzer
I believe this will only remove non-versioned files. Ignored items won't be affected.
0xA3
@0xA3true, I will edit the answer. Thanks for the tip
Thomas Lötzer
You don't need to use the commit dialogue, and you can get ignored files: Right-click | TortoiseSVN | Check for Modifications. Then you can click 'Show Ignored Files' and sort/delete appropriately.
pkh
+3  A: 

Using TortoiseSVN: * right-click on working copy folder, while holding the shift-key down * choose "delete unversioned items"

Stefan
Nice feature! I had to read the link, though, to find out that it only works on the list view (not the tree view) on XP -- maybe you should include that in your answer.
Nick Meyer