Does anybody know a way to recursively remove all files in a working copy that are not under version control? (I need this to get more reliable results in my automatic build
svn st --no-ignore | grep '^[?I]' | sed 's/^[?I] *//' | xargs -r -d '\n' rm -r
This is a unix shell command to delete all files not under subversion control.
Notes:
st in svn st is an build-in alias for status, i.e. the command is equivalent to svn status--no-ignore also includes non-repository files in the status output, otherwise ignores via mechanisms like .cvsignore etc. - since the goal is to have a clean starting point for builds this switch is a mustgrep filters the output such that only files unknown to subversion are left - the lines beginning with ? list files unknown to subversion that would be ignored without the --no-ignore optionsedxargs command is instructed via -r to not execute rm, when the argument list would be empty-d '\n' option tells xargs to use a newline as delimiter such the command also works for filenames with spacesrm -r is used in case complete directories (that are not part of the repository) need to be removed