2006-08-21

Rollback a change with a reverse merge

Problem: A modification is commited to the source tree at revision 481.
After investigations, it appears that the modification done is not correct and the source should actually be like it was in revision 480. How to rollback the changes to the previous revision?

One possible solution is to perform a reverse merge:
$ svn merge -r 481:480 .
-> At this stage, your working copy is like it was at revision 480.
$ svn commit -m "rollback merge to revision 480"
Committed at revision 482.
There might be other way to rollback, but this one is the easiest. The merge will leave your working copy with modified files that you just have to commit.

The situation is a bit different when you are not merging from the head revision to the problematic revision -1. See the following situation: a problematic change is introduced in the file foobar.txt at revision 481. A valid change is added in the file foobar.txt at revision 482. A rollback of the changes introduced at revision 481 will most probably leave your working copy with conflicted changes in the file foobar.txt.


sourcce: cheat sheets