Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo an undesired merge in SVN

We have a repository running SVN. At some moment, to add a feature (lets call it 'branch'), we created a development branch from the main trunk (let's call it 'trunk').

We kept doing our work and commiting to the branch, occasionally, we merged changes made in the trunk into the branch to keep it the branch up to date with the trunk.

At some point, revisions 75051 to 77691 from the trunk were merged into the branch, and commits kept going on the branch, commiting new code in the branch.

But now we want the branch to be up to date with the trunk only up to revision 77089, that is, we want to undo the changes in the branch due to the merge we did, but only changes due to rev77089-77691, without affecting all work done in the branch. Any suggestions to revert or undo the changes in the branch due to rev77089-77691 in the trunk? Thank you very much.

like image 957
Pedro Perez Avatar asked Jul 03 '13 16:07

Pedro Perez


People also ask

How do I undo a merge in svn?

You can use svn merge to “undo” the change in your working copy, and then commit the local modification to the repository. All you need to do is to specify a reverse difference. (You can do this by specifying --revision 392:391 , or by an equivalent --change -392 .)

How do I revert changes in svn?

To roll back local changes in a file under SVN source control, right-click the file and select Source Control > Revert Local Changes and Release Locks. This command releases locks and reverts to the version in the last sandbox update (that is, the last version you synchronized or retrieved from the repository).

How do I revert a specific commit 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.

What is reverse code merge?

A reverse merge is formally the same as a merge, but, of course, in reverse order. Changes from reversely-merged revisions become undone in your working copy.


2 Answers

You can undo a change by simply use a reverse range in your svn merge command:

$ svn revert -R .   #Remove all changes made
$ svn update        #and make sure up to date
$ svn merge -r77691:77088 .

This will get rid of changes from 77089 to 77691 from your working directory.

Or you can undo the merge one revision at a time:

$ svn merge -c -77691 .
$ svn merge -c -77690 .
$ svn merge -c -77689 .
like image 78
David W. Avatar answered Sep 22 '22 07:09

David W.


In addition to the answer of David W. (+1 for that): If you use TortoiseSVN you can open the log (context menu: show log) of your branch, mark all revisions you do not net any more and make a revert (context menu: revert changes from this revision).

like image 24
Micha Avatar answered Sep 21 '22 07:09

Micha