17

We've got a situation where someone messed up a Commit to our SVN server. A lot of files were deleted, etc.

Question: What is the technique for making the previous (to the bad Commit) revision the HEAD revision? I've seen discussion here on SO for doing this for 1 file, but we'd like to make it like that last commit never happened. Any ideas?

All of these answers seem to be correct. I marked abatishchev's answer as the correct answer simply because I'm using Tortoise SVN and it's the method I actually used.

Linger
  • 14,942
  • 23
  • 52
  • 79
jwalkerjr
  • 1,779
  • 4
  • 18
  • 20

5 Answers5

19

The cleanest way would be to undo changes

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 303:302, or by an equivalent --change -303.)

I realize it does not "make it like that last commit never happened" in the sense that commit is still part of history, but I believe it is better to keep that bad commit in the history.
It could include some work in progress that can be queried / compared to, in order to easily remake a new proper commit.


Even if:

  • the SVN (1.5) manual mention a future obliterate command that would accomplish the task of permanently deleting information, and
  • mention svndumpfilter as a possible workaround (in that it provides the ability to quickly and easily modify that dumpfile data by acting as a path-based filter)

... It is better to not try twisting a SCM tool into something it is not meant to do in the first place.
Historization (along with parallelization with branching) are the two main features of an SCM.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    We have no problem keeping the commit, just want to update the HEAD to the proper code base. Gonna give this a try. Thanks. – jwalkerjr Dec 04 '08 at 06:50
9

Maybe you can show log, check previous revision (n-1), in context menu choose Revert to this revision and commit the changes (it will becomes n+1, where n is current bad head)

abatishchev
  • 98,240
  • 88
  • 296
  • 433
  • 1
    http://stackoverflow.com/questions/217190/how-to-quarantine-a-specific-subversion-revision – Milen A. Radev Dec 04 '08 at 12:39
  • 4
    This didn't work for me. When I reverted my local changes to a previous version and tried to commit, svn told me I cant commit until I update my working copy to head which sort of defeats the purpose :/ – Sinaesthetic Oct 23 '13 at 17:34
1

You can do this using svnadmin dump and svnadmin load. It's quite a brute force way to do it, but I believe that's the only way to do it.

The answers to this question may help: Nuking huge file in svn repository

Community
  • 1
  • 1
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 1
    This will break workingcopies that are on the head revision, as they can't update to a version from a version the repository doesn't know about. – Bert Huijben Dec 04 '08 at 10:00
0

You can svn cp specific revisions, so if there are no intervening operations that you wan to save, you could svn rm the offending directory and then svn cp the old version. See the Peg and Operative Revision section of the book

tjw
  • 982
  • 5
  • 7
0

Using TortoiseSVN, if you want to just see the repository at the version before the offending commit:

  • Open the URL with the TortoiseSVN Repository Browser.
  • Note the revision number of that commit and change HEAD to that number - 1 by clicking the button on top right side.

enter image description here

Dio
  • 684
  • 2
  • 9
  • 18