有办法从意外的“ svn 恢复”中恢复吗?

今天早上我做了以下几件事,结果搬起石头砸了自己的脚:

  1. 开始改变我的项目
  2. 对一堆文件做了一些编辑
  3. 意识到我的方法是完全错误的,我需要重新开始
  4. Cd 到我的项目的顶层,并执行“ svn ——递归还原”将我的本地沙盒恢复到预修改状态。
  5. 当我意识到在我当地的沙坑里还有其他一些突出的变化时,我惊恐地嚎叫起来,而我刚刚把它们全部抹去了。(上周五,svn 服务器关闭了,所以我无法将它们签入,而且我已经在周末忘记了它们)

幸运的是,在这种情况下,我在周五下班之前做了一个“ svn diff > tem.txt”,而 tem.txt 文件仍然在我的硬盘上,所以我能够将该文件输入“ patch”并恢复丢失的更改。

但是对于我将来的参考(即下次我再犯同样愚蠢的错误时) ... 有没有办法告诉 svn 撤消“ svn 恢复”?Svn 是否在任何地方保存了本地/未签入差异的备份?

58237 次浏览

No, (absolutely) NO.

If you say to Subversion it should revert a file, all changes are gone by the wind.

Only your memory can get them back.

Exception: New files you had added, will only lose their status "added", but the file will remain in this directory, only status is unknown("?")

Platform / Software exception: Using TortoiseSVN on Windows, Revert first throws the files into Recycle Bin and then reverts them. You can dig into the Recycle Bin to recover the files.

Not really Subversion specific, but if you're working with Eclipse, you can try your luck in the local history.

Now, something a little bit more Subversion specific: if you don't want to make a branch for every change you do, you can keep a couple of trunk checked out locally (trunk-modif-1, trunk-modif-2...). Each "modification" is done on a separate tree and you only need to keep a list of which check out correspond to which modification.

Or you could use Git locally but I never tried it.

There is a solution... go to your recycle bin you'll find there the latest version of the deleted file. Tortoise "throwing" to the recycle bin every file that it revert.

Recently did this mistake of not committing new file changes (about 10) onto SVN and they all vanished because of my silly mistake. But what saved me was the windows "Restore previous versions" option in the context menu. Phew that was a relief and lesson learnt.

If you are using InteliJ then you are a lucky person. On the top menu, you have a Version Control option, and under it you will find local history option, where you will find all the history for selected file, including all the operation you did with that file (update,commit, revert ).

Good luck, Arkde

Also if you have reverted your .NET code (.cs files etc) and you've built your application before revert but after you've made changes, you could recover changes from assembly file using any of the reflector tools to view code.

I reverted solution (Visual Studio + AnkhSVN ) and lose changes of few files. I can't find the file in the recycle bin.

BUT: I recovered my losing files with Handy Recovery, i.e. SVN just delete my files on reverting.

Use any data recovery software to recovery reverted files(like trial Handy Recovery)

You can't recover the files, if you are using svn command-line client.

But you can recover them, if you are using TortoiseSVN as your svn client. TortoiseSVN will automatically move them to your Recycle Bin. You can restore them from there after an accidental revert.

This is a configurable option in TortoiseSVN. It is under Settings -> Dialog 1 -> Use recycle bin when reverting.

By default it is checked, which means files are moved to recycle bin. If you want(mostly you don't care to disable this. If you have a reason, please let me also know)

No, SVN does not keep a log or backup (although there is a solution for TortoiseSVN noted in the other answers).

But in case someone is browsing the answers and did not notice this comment in the OP's question:

"Fortunately in this case I had done an "svn diff > temp.txt" before leaving work on Friday, and the temp.txt file was still on my hard drive, so I was able to feed that file into "patch" and recover my lost changes."

I imagine it is a common paradigm to do 'svn diff' BEFORE you do an 'svn revert'. If you get in the habit of doing this, even if the diff is just echoed to the terminal, you've at least got one possible avenue to recover your lost changes.

I was extremely lucky to find a local change log of the file (Local Revisions) in the history browser in Eclipse. I had been inspecting the differences one by one and I had made a couple of saves on the file before overwriting.