Thursday, May 14, 2009

Revert a change in SVN commit

Suppose you have made an erroneous commit on a particular file, then you can employ the following strategy.


Assume the file we are looking at is SecurityDomainObjectFactory.

Step 1: Do a SVN log on that particular file.

anil@localhost:$ svn log SecurityDomainObjectFactory.java | head -n 25
------------------------------------------------------------------------
r88837 | anil | 2009-05-13 16:55:08 -0500 (Wed, 13 May 2009) | 1 line

JBAS-6857: merge in rev 88834 from trunk
------------------------------------------------------------------------
r85945 | dimitris | 2009-03-16 14:45:12 -0500 (Mon, 16 Mar 2009) | 1 line


Step 2: Determine the two revisions.
In this case, the most recent is 88837 (anil) and 85945(dimitris).


Step 3: Merge it back
$ svn merge -r88837:85945 SecurityDomainObjectFactory.java

Step 4: SVN diff to see the changes are reverted

Step 5: Check in the reverted file
$> svn ci -m "revert the unintentional change" SecurityDomainObjectFactory.java

==================================