What is Reverse Merge ( Revert Merge ) in SVN, a simple explanation and the step by step processes from start to finish
Asked Answered
O

2

21

What is Reverse Merge ( Revert Merge ) in SVN, a simple explanation and the step by step processes from start to finish would be great.

Can someone give me the the processes, numbered if you can. And a good and simple example would be great too.

Outlay answered 22/10, 2013 at 19:32 Comment(0)
H
24

From Tortoise User Guide:

If you want to merge changes back out of your working copy, to revert a change which has already been committed, select the revisions to revert and make sure the Reverse merge box is checked.

From my point of view a reverse merge is a "normal" commit which represents an "anti"-commit to one or more former commits. The former commit will still exist, but the changes become reverted through new "anti"-commit.

Howlend answered 23/10, 2013 at 5:8 Comment(8)
I want a simple explanation with an example pleaseOutlay
If you do a commit which changes the value of a variable form "Foo" to "Bar" than the reverse commit will bring "Foo" back.Howlend
Is the example helpful for you?Howlend
This is very helpful. So is this a bit like Rollback.Outlay
Yes thats right. It is a kind of Rollback. Thanks for accepting (+1 for that).Howlend
I think what you mean when you say "commit" in really called "revision".Upraise
@Douba: Thanks for you input. From my point of view a commit is the action - like a commit - which leads to revision. So I can understand your point of view, but can't see that "commit" (instead of "revision") is wrong.Howlend
@Micha: Thank also for your reply. While I see your point and agree that your usage is not wrong per se, it still becomes very difficult to communicate in a broader community if personal formulations are used instead of ones well-established in a particular field, especially in a delicate and confusion-prone subject such as versioning. In this case, I recommend sticking to SVN's own definitions of terms. There, to commit means "Send changes from your working copy to the repository" (svnbook.red-bean.com/en/1.7/svn.ref.svn.c.commit.html).Upraise
U
10

Short answer

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.

Example

For example, if you want to go back from HEAD to rev. 123, you would reverse-merge like this, assuming your working copy is in HEAD state:

svn merge -r HEAD:123

This will set your working copy in the state of revision 123, but it will formally be based on HEAD. Your working copy state is then the same as if you had manually edited your files back to revision 123. Nothing will have changed in the repository as of yet.

Note that this is not the same as updating to revision 123. If you had done that, although your working copy files would have the same content in both cases, your working copy state would be different: SVN would know that your working copy was based on revision 123 instead of HEAD. If you then tried to commit the changes, it would tell you that you should update to HEAD first, which would undo the update to revision 123, assuming that you have not changed anything in the meantime.

Back to our original scenario. If you are satisfied with the reverse merge, then you can check it in to the repository:

svn commit -m "We undid all changes since r123."

Or, if you feel you have made a mistake, you can revert the reverse merge, which is something completely different, as it only sets your working copy back to the repository state is is based on (in our case, HEAD):

svn revert --recursive .

But be careful with that one, it irreversibly reverts your reverse merge :-). The dot refers to the current directory, and must be specified explicitly (as is not the case with most other SVN commands) as a safety measure to avoid accidentally reverting anything.

Upraise answered 13/5, 2016 at 7:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.