SVN reverse merge?

Svn

Svn Problem Overview


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?)

Svn Solutions


Solution 1 - Svn

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.

Solution 2 - Svn

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

Solution 3 - Svn

Solution 4 - Svn

For anyone using TortiseSVN, you can just bring up the "Show Log" dialog revert commits from there:

http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-howto-rollback.html

Solution 5 - Svn

To back out of an undesired change (perhaps you committed other files that had debugging statements in them, along with something you really did want to commit), say the bad change was -r10:

svn update
svn merge -r10:9 <URL of your repository base> .

Now you can bring back just the file you did want to commit:

svn update
svn update -r10
svn commit <just that one file>   # this is the command you meant to type from the beginning


Solution 6 - Svn

If you want a quick and reliable way to rollback to a particular revision, then just check out the older revision of the repository.

Run svn info to remind yourself what your repository URL is, then create a new folder and checkout the revision you want:

cd <your new folder>
svn checkout <URL> -r 497 .

Then you can diff that folder against your existing folder, and you can commit that entire revision back into the repository from there if you need to.

Solution 7 - Svn

Solution 8 - Svn

Consider HEAD:150 revert r1=100 and r2 =90

  1. svn up
  2. svn merge -r 100:99
  3. svn merge -r 90:89

Note: These changes will not revert EXTERNALS folder!

Solution 9 - Svn

Reverse merge In SVN

  • if it is file level

  • SVN will keep common file contents in working copy from the specific revision of file and HEAD revision of working copy.

  • if it is folder level

  • In SVN reverse merge, if not file found in the specific revision, it keeps the working copy as it is.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRicketView Question on Stackoverflow
Solution 1 - SvnUpgradingdaveView Answer on Stackoverflow
Solution 2 - SvnSander RijkenView Answer on Stackoverflow
Solution 3 - SvnsakabakoView Answer on Stackoverflow
Solution 4 - SvnyellavonView Answer on Stackoverflow
Solution 5 - SvnEtherView Answer on Stackoverflow
Solution 6 - SvnDan JView Answer on Stackoverflow
Solution 7 - SvngauravtechieView Answer on Stackoverflow
Solution 8 - Svnpiyush89View Answer on Stackoverflow
Solution 9 - SvnShyamasundara NView Answer on Stackoverflow