TortoiseSVN - Undoing a Revert
Asked Answered
D

5

12

I wanted to look at (and not modify) older versions of a few files in my repository, so I went and reverted those files. Now I'm trying to get those files back to the most recent version so that they match all the other files in my working copy, but when I updated the folder, nothing changes.

Is it possible to undo a revert? I copy and pasted the newest versions of those files elsewhere, so they're not completely lost, but I would think that there's an easier way than just moving those files back to the directory holding my working copy.

Thanks in advance.

Donegan answered 28/11, 2011 at 8:9 Comment(1)
See detailed answer and procedure here: #1554778Bulbous
Q
9

I guess you used the Revert to this revision context menu in the Show log dialogue. Despite the name, it doesn't really perform a revert operation, not at least in the way Subversion understands the term. What it actually does is a reverse merge of the revision changes into your working copy. So now you have unsaved changes in your working copy and Subversion tries to preserve them when you update. You can verify that from the "Check for modifications" dialogue: those items should display as "Modified".

If that's the case, you can discard your local changes the usual way: the "Revert" context menu in your working copy. This time, it will do a real "revert" operation.

Next time you want to inspect old versions of a directory tree you can use the "Update item to revision" context menu in the log dialogue. It will do a SVN update that can be easily undone.

Qua answered 28/11, 2011 at 8:32 Comment(3)
Yes, that's what I did; I didn't realize that the terminology differed. I followed your instructions, and I got my most recent files back in my working directory. Thank you for your help! I'm not quite sure what you mean by "reverse merge" though. Can you please explain what that means?Donegan
A merge is the operation of copying changes made to one branch into another branch. It's reverse when you don't apply the changes to get the feature but their opposite (to remove the feature).Triple
Sorry, but "Revert to this revision" really does a reverse merge. An "update to this revision" does not however.Bennington
L
19

Press Ctrl + Z in the project directory if you haven't restarted your computer

Lustreware answered 22/2, 2013 at 14:28 Comment(3)
This one did help me. The project was open in Visual Studio, so I could selectively undo the reverts!Chuch
Never knew that was possible. Saved me a lot of time. Thanks!Helminth
You save my day :)Flat
Q
9

I guess you used the Revert to this revision context menu in the Show log dialogue. Despite the name, it doesn't really perform a revert operation, not at least in the way Subversion understands the term. What it actually does is a reverse merge of the revision changes into your working copy. So now you have unsaved changes in your working copy and Subversion tries to preserve them when you update. You can verify that from the "Check for modifications" dialogue: those items should display as "Modified".

If that's the case, you can discard your local changes the usual way: the "Revert" context menu in your working copy. This time, it will do a real "revert" operation.

Next time you want to inspect old versions of a directory tree you can use the "Update item to revision" context menu in the log dialogue. It will do a SVN update that can be easily undone.

Qua answered 28/11, 2011 at 8:32 Comment(3)
Yes, that's what I did; I didn't realize that the terminology differed. I followed your instructions, and I got my most recent files back in my working directory. Thank you for your help! I'm not quite sure what you mean by "reverse merge" though. Can you please explain what that means?Donegan
A merge is the operation of copying changes made to one branch into another branch. It's reverse when you don't apply the changes to get the feature but their opposite (to remove the feature).Triple
Sorry, but "Revert to this revision" really does a reverse merge. An "update to this revision" does not however.Bennington
H
3

With SVN there's only the working copy on your local machine, and the repository on the server. By using revert you have replaced the contents of your local working copy with the contents from the server, and there is no other place where SVN keeps a copy of those files.

Depending on your IDE you might be able to restore your changes. Eclipse, for example keeps track of the local history of every file in your workspace.

But if you want to get version control that is much more flexible, take a look at Git or Mercurial.

Hoplite answered 28/11, 2011 at 8:18 Comment(1)
Mentioning this Eclipse feature just saved me from a good chunk of rework!Neisa
N
3

There is a solution... go to your recycle bin you'll find there the latest version of the deleted file. Tortoise "throwing" to the recycle bin every file that it revert.I hope you will get your files there.

Nabors answered 30/8, 2018 at 13:34 Comment(0)
N
0

No. Reverting discards your local changes that the repository never heard about, so there is no way to restore them from there. TortoiseSVN could probably keep backups for you on the client side, but doesn't.

Note that this only means that you'll never get back local modifications that weren't committed, an Update command should still get you the latest version from the repository, not any old versions that you had explicitly checked out before.

Normalcy answered 28/11, 2011 at 8:14 Comment(3)
Thank you for your response. I didn't actually make any local changes when I reverted those files though. Let's say my folder was at version 100 (which is the latest version in the repository), and I reverted a few files to version 50. So now I want those files in my working copy back to version 100 (and unless I'm misunderstanding something, version 100 of those files are still sitting in the repository). I haven't committed anything during this process. Is there no way to get back to version 100 of these files because I reverted them to version 50 earlier?Donegan
Okay, so in SVN terminology, you didn't "revert", you "updated" (yeah, not exactly identical with everyday usage) to a specific revision number using the TortoiseSVN -> Update to revision... dialog?Normalcy
Yeah, I didn't realize the SVN terminology and TortoiseSVN terminology differed a bit. What I did for each file was TortoiseSVN -> Show Log -> Revert to this revision, as Alvaro G. Vicario described in another answer. Thank you for helping!Donegan

© 2022 - 2024 — McMap. All rights reserved.