Subversion: Revert to a Previous Revision

On one of my current projects, I had the problem that I had done several commits to the repository and suddenly changed my mind and wanted to go back to a certain point in the revison history where I started with my changes. How would you do that?

Let’s say you started your changes at revision 901 with your first commit and the current revision (HEAD) is 910.

To your working-copy you could just do:

svn up -r 900 .

But that would bring back the unwanted changes to you as soon as you update again and would not affect other people working on the code when they update their workig copies to the current revision. What you really have to do in this case is to ‘merge back’ your working-copy and then commit the changes with a comment:

svn up;
svn merge -r HEAD:900 .;
svn commit -m "Reverted back to rev 900. Sorry, changed my mind.";

Be careful! This only works if ALL revisions (901-910) have been committed by yourself.