Sometimes you when you have a lot of changes in your working copy that you don't need anymore you simply want to reset your working copy to an unmodified state. Unfortunatlety there is no simple svn command to do the job. That's why I've written the
svn reset functionality myself.
To reset a svn working copy you need to do two things:
- revert all changed files
- remove all files not under version control
To do this I've created a new function in my .aliases files:
if [[ $@ == "reset" ]];
command svn revert --recursive . && svn status | grep ^\? | cut -c9- | xargs rm -r;
else command svn "$@";
It has the same name as the svn executable so I can simply type
svn reset. The function first checks whether is has been called with "reset" and if so executes the reset functionality. Otherwise it just delegates to the svn executable, so all the other build-in commands still work. If
svn reset has been called it will revert the working copy recursively from the current working directory (so it will only reset the whole working copy if you're in the root directory). After reverting the working copy there may be untracked files left, so those files have to be identified using
svn status and then be deleted.