Search code examples
svnsvn-checkout

Clean an svn checkout (remove non-svn files)


Id like to remove all files in my working copy that are not known in the svn repository.

Effectively as if I'd just made a clean checkout, but Id rather not have to re-download all files.

The closest think I've come to this is...

rm -rf `svn st | grep "^?" | cut -d" " -f8`

But this seems clunky and I don't totally trust it since inconsistency in output could remove dirs outside svn.

"svn export" isn't what Im looking for because I'm not cleaning the source to package it, I just want to remove cruft mostly (*.pyc, *.orig, *.rej, svn-commit.tmp, *.swp).

Is there a better way to do this besides making a clean checkout?


Solution

  • Most solutions that are posted here fail to handle folders with whitespaces. This is why we use this one:

    svn status --no-ignore | grep '^[?I]' |  sed "s/^[?I] //" | xargs -I{} rm -rf "{}"