18.01.08

Delete Unversioned Files Under SVN

Posted in Linux, Tips at 1:20 pm by Guy

Sometimes svn switch fails because unversion files exist in the working copy, and the need to erase them comes up. This is also true when updating to an old revision (usually one that misses directories that exist in the head revision), doing some work (like compiling), and then trying to update back to the head revision. Subversion (SVN) will fail complaining that directories/files already exist.

The cause of the problem is that the working-copy isn’t clean, it has some (or a lot) of unversioned files. The best solution will be to delete all of them. While this can be a tedious task when done manually for each file, it can be achieved with single shell command.

svn status --no-ignore | grep '^\?' | sed 's/^\?      //'
svn status --no-ignore | grep '^\?' | sed 's/^\?      //'  | xargs rm -rf

The first command will list all unversioned files and directories. Use this to review the files to be deleted. After you review the files, use the second command to delete them easily.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

1 Comment »

  1. gilesc said,

    February 9, 2008 at 8:46 am

    Thanks!

Leave a Comment