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? Essential
With powershell:
(svn status --no-ignore) -match '[?]' -replace '^.\s+' | rm
From command line:
powershell -Command "&{(svn status --no-ignore) -match '[?]' -replace '^.\s+' | rm}"
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]//'`
Somebody said you can't do it from the Windows command line.
Bull.
for /f "tokens=2 delims= " %I IN ('svn st --no-ignore ^| findstr /R "^[I?]"') DO (DEL /S /F /Q /A:H "%I" & rmdir /S /Q "%I")
Does it in one line and doesn't require a single GNU tool. :)
Using TortoiseSVN:
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.
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.
I know this is old but in case anyone else stumbles upon it, newer versions (1.9 or later) of svn support --remove-unversioned
, e.g. svn cleanup . --remove-unversioned
.
https://subversion.apache.org/docs/release-notes/1.9.html#svn-cleanup-options