Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The latest revisions in my code repo has been corrupted and has destabilized my app. I want to revert to an earlier revision.

But I don't want to simply use 'revert' on my working copy; I actually want to delete my head revision and several revisions prior in my repo, thereby 'reverting' my repo to an earlier revision, which would become the head revision. Anyone know how I would do this?

share|improve this question
1  
You can't really delete old revisions, all you can do is reverse the changes, and commit that, as mentioned by Felix. Interesting sidenote, Git (as well as other version control solutions) actually does allow you to truly delete revisions.. –  davr Jan 13 '10 at 20:51
2  
Yes you can, you just need access to the SVN repository with svnadmin. See my answer below. –  martin Jul 26 '11 at 7:45
    
davr is technically right. What you describe is dumping all revisions except the bad ones, then dumping this on top of the old repo. In my mind that's not really the same thing as 'deleting' a revision. –  Sirex Jul 26 '11 at 9:42
add comment

4 Answers 4

up vote 10 down vote accepted

Maybe this link helps you:

http://www.sampablokuper.com/2009/03/27/svn-revert-to-revision/

Quote:

  1. Change to the top directory within your working copy (assuming you want to roll back the whole of the working copy).

  2. run svn revert to revert your working copy's files to the state they were in when you last committed/checked out.

  3. run svn status -v to see which revision number your working copy now corresponds to (it's the highest revision number in the list that svn status -v produces).

  4. run svn merge -rXX:YY where XX is the number you obtained in the previous step and YY is the number of the revision you want to revert to.

  5. Done! The possible exception to this is that files in your working copy that didn't exist when revision YY was originally made, will still be there, because by default svn doesn't remove things. If you want to get rid of them, run a svn del [filename] on each of them.

  6. Well done! Now play with your working copy as though all those intermediate edits had never happened . And when you're ready to commit your efforts, just use svn commit as usual!

share|improve this answer
    
In Windows Os, option #4 run svn merge -rXX:YY . Remember to put a dot at the end of line to reference the current directory. And in TortoiseSVN, there is an option to reverse merge. –  Shantha Kumara Mar 1 '12 at 8:15
    
This does not actually revert to "earlier revision, which would become the head revision". It doesn't make the older revision the HEAD. Rather, it creates a new HEAD. See martin's answer. –  Matthew Flaschen Jul 12 '12 at 23:34
add comment

This worked for me. Given that you have revision 1234 as the HEAD and you want to revert last three commits:

svnadmin create newrepo
svnadmin dump -r 0:1231 repo | svnadmin load newrepo
mv repo oldrepo
mv newrepo repo
share|improve this answer
3  
+1. You're the only one who both understood the question and gave a specific answer. –  Matthew Flaschen Jul 12 '12 at 22:58
    
This is technically the right answer. It should be pointed out, however, that this, apart from possibly being rather complicated to do, will also invalidate all checked-out copies - so you'll need to alert anyone who is also using the repo. –  sleske Dec 17 '12 at 16:18
    
quick and easy and to the point and actually what the poster asked for. –  Ryan Wiancko Apr 11 '13 at 3:23
1  
As long as you make sure to also copy the repository UUID over to the new repo (see "svnadmin setuuid", copying from the UUID in "svn info" on the old repo), only checkouts updated to the revisions you are cutting out will be invalidated. –  Bryan Petty Jun 13 '13 at 15:27
    
+1. can you delete file versions that you dont need anymore in order to trim the repo? like "if the file has 100 revisions, delete 40-60" or this messes up the change sets? –  Tomer W Jan 14 at 18:41
add comment

You can use dump / load for this purpose.

You could also use svnsync to make a backup to some revision.

If you have a big repository, it take time.

share|improve this answer
add comment

I know this is an old question, however, I've just found how to do this with Windows/TortoiseSVN.

As a comment suggested, you can't "delete" a revision, but what you can do is make a more current revision that is the same as the revision you want to revert to.

  1. Checkout the HEAD of the repository for the directory you want to revert the revision from.
  2. Load the "Show Log" view in TortoiseSVN for the highest level directory you want to revert (e.g. "Trunk").
  3. Right-Click the revision you want to remove NOTE: this is the revision you want to remove, not the one you want to revert to.
  4. Select "Revert changes from this revision".
  5. Click "Yes" at the prompt.
  6. Update the checkout as normal, but to "HEAD".
  7. Commit it back.

You will then to go to everyone else who has it checked out and get them to update and make sure to remove any new files.

Also, you'll need to make sure that everyone knows what that revision was and potentially update the description.

share|improve this answer
    
how is that different from the normal "revert" procedure? –  Tomer W Jan 14 at 18:44
    
A Revert just changes your working copy to what is in the repo... this is how to make the HEAD of a report reflect the state of any previous commit. –  Martin Jan 15 at 0:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.