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.

One thought on “Revert back changes in subversion”

  1. This command will only revert a single change. If the file has had multiple changes since the version you want to go back to, then you would need to undo each series of changes one at a time, much like peeling back the layers of an onion.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax