Reverting to a previous revision using TortoiseSVN
Asked Answered
P

6

65

What is the easiest way to revert my working copy to a previous revision using Windows TortoiseSVN?

I did not find any "findable" command to do that quickly.

Pinball answered 31/3, 2011 at 17:35 Comment(0)
V
130

There are several ways to do that. But do not just update to the earlier revision as suggested here.

The easiest way to revert the changes from a single revision, or from a range of revisions, is to use the revision log dialog. This is also the method to use of you want to discard recent changes and make an earlier revision the new HEAD.

  1. Select the file or folder in which you need to revert the changes. If you want to revert all changes, this should be the top level folder.
  2. Select TortoiseSVN → Show Log to display a list of revisions. You may need to use Show All or Next 100 to show the revision(s) you are interested in.
  3. Select the revision you wish to revert. If you want to undo a range of revisions, select the first one and hold Shift while selecting the last one. Note that for multiple revisions, the range must be unbroken with no gaps. Right click on the selected revision(s), then select Context MenuRevert changes from this revision.
  4. Or if you want to make an earlier revision the new HEAD revision, right click on the selected revision, then select Context MenuRevert to this revision. This will discard all changes after the selected revision.

You have reverted the changes within your working copy. Check the results, THEN COMMIT the changes.

All solutions are explained in the "How Do I..." part of the TortoiseSVN docs.

Vergne answered 1/4, 2011 at 13:3 Comment(8)
So if i do the this above step i can't able to get the other revisions which are created after the revision i reverted? Will revisions created after the revert revisions are deleted? I don't want to lose anything i want to switch back to one particular revision. How to do that? ThanksAmmonify
I think i found it. I need to do Update to revision. Am i right?Ammonify
No! Do NOT use "update to revision". Read the first line of my answer.Vergne
Hi thanks for your reply. +1 for your time and answer. I couldn't understand few things like revert back. will it delete current version present now, if i revert back? I think i need to read about intermediate basics about subversion. I know there is docs in tortoisesvn.net/docs but i need basic defenition rather than usage. so if i got the definition i can use it with the documentation. Can you provide me some link or book referenceAmmonify
Okay i got it. That i need to revert back instead of update to revision as it won't allow me to commit a new version. I got this from @Vincent B comment. I followed your step still point 3. I can able to commit new versions now. Any way you can give a reference to me to find basics. ThanksAmmonify
I am just trying to understand the semantics of the phrasing. By way of example, say I have checked in revision 2 and revision 3, then decide I want to back out revision 3. When you say "Select the revision you wish to revert" do I select revision 2 or revision 3? My history log gives me two different options when I right click on a file - "revert to" and "revert from". It's confusing because "reverting" a file could mean the newest revision of the previous revision depending on the context. So which file do I select and which option do I choose?Hydrometer
Hi there, I tried following your method, but I cannot commit after revert, The files supposed to commit shows a tick icon, and when try to commit, the commit window does not show the file to be available for commit.Presumptuous
Also make sure you are up to date, or Tortoise may tell you it reverted without actually making any (or the right) changes, and there may be no changes to commit.Catalyze
D
10

I have used the same instructions Stefan used, taken from Tortoise website.

But it's important to click COMMIT right after. I was getting crazy until I realized that.

If you need to make an older revision your head revision do the following:

  1. Select the file or folder in which you need to revert the changes. If you want to revert all changes, this should be the top level folder.

  2. Select TortoiseSVN → Show Log to display a list of revisions. You may need to use Show All or Next 100 to show the revision(s) you are interested in.

  3. Right click on the selected revision, then select Context Menu → Revert to this revision. This will discard all changes after the selected revision.

  4. Make a commit.

Dairying answered 9/6, 2014 at 12:31 Comment(0)
S
5

Right click on the folder which is under SVN control, go to TortoiseSVNShow log. Write down the revision you want to revert to and then go to TortoiseSVNUpdate to revision....

Enter image description here

Skees answered 31/3, 2011 at 17:41 Comment(3)
Pretty sure you can right-click a revision in the log and choose "Update to this revision"Gelderland
Yes you can, but i just wanna show one of the ways of doing that. There are several ways.Skees
Update to revision does not allow you to commit the changes. Once updated, you cannot commit the change since the version of your working copy will be the same one than the one you want to revert it from. You need to use the "revert to revision" to do what @Ricardo Alamino want to do.Halpin
S
1

The Revert command in the context menu ignores your edits and returns the working copy to its previous state. You may also select the desired revision other than the "Head" when you "CheckOut" from the repository.

Stammer answered 31/3, 2011 at 17:41 Comment(0)
U
1

Here's another method that's unorthodox, but works*.

I recently found myself in a situation where I'd checked in breaking code, knowing that I couldn't update our production code to it until all the integration work had taken place (in retrospect this was a bad decision, but we didn't expect to get stalled out, but other projects took precedence). That was several months ago, and the integration has been stalled for that entire time. Along comes a requirement to change the base code and get it into production last week without the breaking change.

Here's what we did:

After verifying that the new requirement doesn't break anything when using the revision before my check in, I made a copy of the working directory containing the new code. Then I deleted everything in the working directory and checked out the revision I wanted to it. Then I deleted all the files I'd just checked out, and copied in the files from the working copy. Then I committed that change, effectively wiping out the breaking change from the repository and getting the production code in place as the head revision. We still have the breaking change available, but it's no longer in the head revision so we can move forward to production.

*I don't recommend this method, but if you find yourself in a similar situation, it's a way out that's not too painful.

Unshapen answered 19/3, 2018 at 15:56 Comment(0)
Y
-1

In the TortoiseSVN context menu, select 'Update to Revision', enter the desired revision number, and voilà :)

Yablon answered 31/3, 2011 at 17:40 Comment(2)
It should not. If you want to revert user edits, use 'Revert'.Yablon
Update to revision makes your working copy point to an old revision. From the moment you try to do a commit it will complain that your working copy is out of date.Nehemiah

© 2022 - 2024 — McMap. All rights reserved.