Clean up a subversion working copy

July 28, 2010 by alex

You could just delete your working copy and check out a fresh one. In my case, that takes hours. So I wanted to find a way to remove all local modifications.

svn st \
  | awk '{ if ( $1 == "?" ) print $2 }' \
  | xargs rm -Rf svn st \
  | awk '{ if ( $1 == "M" ) print $2 }' \
  | xargs svn revert

Remove all files whos' svn status is ‘?’, meaning not part of version control. Then revert changes in any file which has an “M” (modified) status.

svn st You should now have no local changes or unknown files.

WARNING xargs may not do the right thing if your file names have spaces or other special characters in them. Check man xargs for more details before running these commands.

☙ ☙ ☙