Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN reverse merge?

Tags:

svn

My SVN repository was perfect at revision 497. I performed several bad commits, so that now it is at revision HEAD. I see that to rollback you should use a command like this:

svn merge -r HEAD:497 . 

while in the working directory (and the working directory is at the HEAD revision). But is that the right command? Or do I use HEAD:498? or 496? I already ran that command and the current revision doesn't appear to be the same as 497, because when I update -r 497 (or when I have a 497 working copy and I update -r HEAD), a lot of file updates occur.

Do I have some sort of fencepost problem, where HEAD:497 actually reverts to 496, or something? Or is it that when I update, SVN goes back through each revision, despite the fact that the HEAD and 497 are identical?

Edit:

Just to clarify, as I said earlier when I update between 497 and my merged HEAD, I see a lot of file changes take place. I thought that if 497 and HEAD were identical, it would detect that, and no file changes would occur; it would simply say "Updated to revision 497." So is my command wrong, or is this thinking wrong? (and if so, why?)

like image 646
Ricket Avatar asked Dec 18 '09 21:12

Ricket


People also ask

How do you do reverse 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 .)

Can we revert commit in svn?

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.

What is reverse code merge?

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.


2 Answers

If your repo was in pristine condition at revision 497, then I think you're correct, you need to do a:

svn merge -r HEAD:497 . 

That merge command will only change files in your working copy, so remember to also commit the changes to update HEAD in the repo.

After you do the merge, followed by the commit, try comparing revision 497 to HEAD and they should be identical.

like image 153
Upgradingdave Avatar answered Oct 08 '22 19:10

Upgradingdave


If you want to undo r123, you need to svn merge -r 123:122 .

This means you need to run

svn merge -r HEAD:497 . 

To verify run:

svn diff -r 497 
like image 30
Sander Rijken Avatar answered Oct 08 '22 18:10

Sander Rijken