Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the HEAD to a previous revision

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.

like image 622
jwalkerjr Avatar asked Dec 04 '08 06:12

jwalkerjr


People also ask

How do I revert in TortoiseSVN?

If you want to undo all changes you made in a file since the last update you need to select the file, right click to pop up the context menu and then select the command TortoiseSVN → Revert A dialog will pop up showing you the files that you've changed and can revert. Select those you want to revert and click on OK.

What is Update to revision in svn?

svn update brings changes from the repository into your working copy. If no revision is given, it brings your working copy up-to-date with the HEAD revision. Otherwise, it synchronizes the working copy to the revision given by the --revision option.


3 Answers

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.

like image 96
VonC Avatar answered Oct 04 '22 20:10

VonC


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)

like image 37
abatishchev Avatar answered Oct 04 '22 20:10

abatishchev


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

like image 29
Greg Hewgill Avatar answered Oct 04 '22 21:10

Greg Hewgill