3

Ack! I just mistakenly ran "svn revert somefile" with the wrong filename pasted in. Now my nicely modified file is gone!

I'd like a "svn unrevert" command. AFIK there's no such thing. What is the next best way out of this mess?

DarenW
  • 16,549
  • 7
  • 63
  • 102
  • Nothing I have ever seen. Bad luck mate. – DaveShaw Oct 09 '10 at 00:34
  • Agreed, I don't believe this is possible with SVN. Use "revert" sparingly, better to check in something bad and have to roll back than to not check in something good :) – David Oct 09 '10 at 00:36
  • Just found this question is redundant with the older http://stackoverflow.com/questions/1521332/is-there-a-way-to-recover-from-an-accidental-svn-revert – DarenW Dec 22 '10 at 16:46

6 Answers6

6

There's no way to un-do a revert. You can revert because Subversion keeps a copy of the original file inside the .svn folder, and when you run the revert command the backup copy is copied over the file in your working copy. Subversion doesn't back up your modified file before it performs the revert, so unless you made a copy of it somewhere you are probably out of luck.

bta
  • 43,959
  • 6
  • 69
  • 99
  • 2
    That being said, if you still have the file open in an editor, you may be able to recover it. Add a space somewhere and save the file, and the copy in the editor's memory (which contains your modifications) should be saved over the copy on the disk. – bta Oct 09 '10 at 00:52
4

If you use Eclipse or IDEA they store local history, and you can use it to restore your changes. I don't think there is any other way.

Andrey Breslav
  • 24,795
  • 10
  • 66
  • 61
3

If you use Tortoise SVN:

  1. Right click in any directory that's part of an SVN working copy
  2. Select "Settings" from the TortoiseSVN menu.
  3. Click on "Dialogs 1"
  4. Check "Use recycle bin when reverting"
Tyler
  • 21,762
  • 11
  • 61
  • 90
1

An undelete utility.

I like File Scavenger.

It's hit and miss, but you have a chance of getting your file back. The less disk activity since the delete, the greater your chance.

  • I've found with FS that old versions of the same file persist. NTFS != FAT. –  Oct 09 '10 at 09:21
1

It might have preserved the file as it was before the revert under another name, ${FILENAME}.orig or ${FILENAME}~ or some such. If it didn't, sorry, you're out of luck.

zwol
  • 135,547
  • 38
  • 252
  • 361
  • I use kwrite, which saves (filename)~ but I had turned off that feature, annoyed at all the filenamed ending with ~ appearing everywhere. :( – DarenW Oct 11 '10 at 14:54
0

Sorry to say, but that is not possible.

Alan Haggai Alavi
  • 72,802
  • 19
  • 102
  • 127