Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to roll-back a change set using Subversion?

I've been using various source control systems for a while, but when it comes to reverting changes I'm not yet an expert. Can someone help given this scenario:

Scenario

  • Given a bug was introduced in revision #5
  • And 3 files were changed in revision #5
  • And changes in 2 files were responsible for the bug
  • When the customer discovers the bug in a release of revision #9 (HEAD)
  • Then 2 of the files causing the bug from revision #5 must be reverted to revision #4
  • And changes from revision #6 to HEAD must be applied to the two files

I expect there must be a way to compare revisions #4 and #5 of the two files and generate a patch that undoes the changes in revision #5, which can then be applied to the HEAD revision to roll-back the defect.

like image 550
Robert Walker Avatar asked Oct 16 '08 20:10

Robert Walker


People also ask

How do I roll back a revision in svn?

Right click on the selected revision(s), then select Context Menu → Revert changes from this revision. Or if you want to make an earlier revision the new HEAD revision, right click on the selected revision, then select Context Menu → Revert to this revision. This will discard all changes after the selected revision.

How do I undo changes in svn?

If you want to undo all changes you made in a file since the last update you need to select the file, right click to pop up the context menu and then select the command TortoiseSVN → Revert A dialog will pop up showing you the files that you've changed and can revert.

How do you revert changes in svn after commit?

To revert a single commit: Go to: Subversion -> Integrate Directory... Show activity on this post. Note that the svn merge command reverts a commit in the sense of having another commit undoing your changes, but keeping your wrong commit in the history.


2 Answers

Usually a reverse merge will be sufficient to roll back a committed changes...

like image 169
Christian C. Salvadó Avatar answered Oct 14 '22 18:10

Christian C. Salvadó


To read up on the details see: svn manual - Undoing Changes

As described by mark you'll want to do:
svn merge -r 5:4 file1 file2
This means merge in the change from 4 to 5 backwards ie. undo the changes

You could also type:
svn merge -c -5 file1 file2
This means apply the change that took place in commiting revision 5 backwards.

Next you should manually review the changes.

Finally you must commit the changes (above merges only changed your working copy).

like image 40
morechilli Avatar answered Oct 14 '22 18:10

morechilli