You are here: Home / Documentation / How To's / How to back out or undo your svn commit

How to back out or undo your svn commit

by nguyen — published Jun 04, 2009 11:50 AM, last modified Aug 16, 2016 10:50 AM
or, "Oops, I committed it again!"

Hm, I noticed today (couldn't help it, really) that if you forget that "svn commit" will commit everything in the entire tree where you are AND BELOW, you could end up wishing you could undo your commits.

Here is what I had done: svn commit -m 'blabla'

resulting in revision 1342. 

The problem is that not only did it commit what I wanted it to commit, it also committed some changes I'd made a while back but had forgotten to either revert or commit... oops!

To revert the repo back to what was in 1341, 

  1. svn update
  2. svn merge -c -1342
  3. svn stat
  4. svn commit -m 'mucking about trying to undo my dorky commit'

The 'svn update' brings your working copy in sync with what's in the repo.

The 'svn merge' basically says 'remove the changes in revision 1342'.

The 'svn stat' is so you can verify that the merge command backed out your changes.

The 'svn commit' makes those changes final in the repo.

The new revision (in my case, 1343) is now back to what was in revision 1341.