Friday, October 13th, 2006

Revert back changes in subversion

Filed under: — Daniel Lemire @ 16:02

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.

1 Comment »

  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.

    Comment by Joe — 4/10/2007 @ 10:25

RSS feed for comments on this post.

Leave a comment

Warning: When entering a long comment, please ensure that you make copy of your text prior to submitting it. If the server should fail or if you hit a bug, you might lose your work. I am not responsible for your lost effort.

To spammers: I carefully review every single post and make sure that spam gets deleted. You are wasting your time if you are manually entering spam using this form. Read my terms of use to see what I consider to be abusive.

Example: I + II + IX= XII. Yes, you have to enter a roman numeral. (Answer must be in upper case.)

« Blog's main page

38 queries. 1.284 seconds. Valid XHTML

Powered by WordPress

Subscribe to this blog in a reader or by Email.