Posts in category subversion

Reverting changes in Subversion

I just made a comment to a blog post asking about how to best revert changes to files in Subversion:

Make old svn revision the current revision

Looking up my wiki notes, I remembered I had a solution to this. As it may be of interest to others, here is my comment in full:

The trick is actually to use svn merge, and reverse the arguments to do a ‘negative’ (reverse) merge - as opposed to the usual forward merge where one compares old:new.

svn merge -r HEAD:247 myfile.php

Remembering that a changeset of a given number takes the revision of the repos to the same number, this will reverse any changesets down to (and including) 248 - but not 247 itself as that change is a delta against 246.

For any one-off mistakes, this can be simplified for individial changesets like this (this time just changes from changeset 248):

svn merge -c -248 myfile.php

Update: I was sure I got the first comment in as none was posted when I made mine. Turns out commenting was moderated, and 5 others had already pointed to the same solution - with some additional links to further reading (nice).

  • Posted: 2008-05-29 15:23 (Updated: 2008-05-29 15:28)
  • Categories: subversion
  • Comments (0)