23

I committed some bad code changes to my SVN sever using TortoiseSVN.

Now the head revision is 155, but I would like to delete the last 2 revisions so that the head revision is 153. In other words, I would like to "undo" my last two commits.

How can I do this using TortoiseSVN? Does an option exist in the TortoiseSVN menu, or do I need to use the command line?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user974967
  • 2,928
  • 10
  • 28
  • 45

5 Answers5

14

If you open the SVN Log, you can then right-click on a revision and use the options Revert to this revision or Revert changes from this revision. Both of these options will update your working copy (which you can then commit).

There are no options within TortoiseSVN to delete revisions.

Luke Z
  • 2,369
  • 1
  • 17
  • 13
  • If you really need to delete (I don't suggest it unless there was major corruption), there is some information [here](http://superuser.com/questions/95432/want-to-delete-revisions-from-my-svn-repository). – Luke Z Dec 05 '12 at 00:30
  • I do not see Revert option from SVN Log. Any idea why? – Techie Jun 30 '23 at 12:02
3

Being at the root of your updated working copy, you should use the following command:

svn merge -rHEAD:153 .

That will 'undo' all your changes from revision 153 so that your revision 156 will look like revision 153.

Don't forget to commit afterwards!

You can do the same from TortoiseSvn: Open the 'Show Log' interface, select the revision 153, right-click it and select 'Revert changes from this revision'.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yannick Blondeau
  • 9,465
  • 8
  • 52
  • 74
  • @perhaps you need to do resolve conflicts after reverting changes from this revision and then commit it. It is good that removed the revisions that deleted the files. Thanks! – Espanta Apr 21 '20 at 20:27
2

Unfortunately, with TortoiseSVN (or any other SVN client) there is no way to really delete a revision, in the sense that it completely disappears from the history. Changing the history of an SVN repository is hard, and requires manipulation on the server - see this question: Why isn't obliterate an essential feature of Subversion?

However, you can "undo" a checkin, by making a new checkin that changes it back. This is usually done with a technique called "reverse merge". See e.g. Retract accidental checkin

Community
  • 1
  • 1
sleske
  • 81,358
  • 34
  • 189
  • 227
2

I have used these instructions 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.

ilans
  • 2,537
  • 1
  • 28
  • 29
  • That just does nothing. It does not deletes old commit, but just adds another one. Fixing changes? Yes, of course. But not deleting at all! – user2501323 Dec 20 '19 at 07:14
0

From the command line:

Revert changes to a file:

svn merge -r <newBadRev>:<oldRevToMergeBackTo> <filename>

For example:

svn merge -r 155:153 myfile.cpp
phonetagger
  • 7,701
  • 3
  • 31
  • 55