Daniel Lemire's blog

, 1 min read

Revert back changes in subversion

Suppose you have incorrectly checked in a change to a file in a subversion repository. How do you revert back? This is documented elsewhere, but I want to document just exactly how I do it.

First of all, you need to know what are the most recent versions of your file, to figure it out, just do:


svn log myfile | head -n 10

where “-n 10” is meant to only give you the first 10 lines of the log files, but you may need more if the comments are exhaustive. This should give you the latest revisions. Say they are 122 and 227, then just do reverse merge, like so:


svn merge -r 227:122 myfile
svn diff myfile
svn ci

The command “svn diff” is necessary to make sure that, indeed, you have reverted back the right changes.