Eclipse 的本地历史记录...文件保存在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/969782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:46:32  来源:igfitidea点击:

Eclipse's local history...where are files saved?

eclipseflexbuilderhistorylocal

提问by VonC

Can someone explain how Eclipse's local history works?

有人可以解释 Eclipse 的本地历史是如何运作的吗?

I accidentally overwrote a file in a project but need to revert to an earlier version. Is there a chance that Eclipse has the older file cached somewhere?

我不小心覆盖了项目中的文件,但需要恢复到早期版本。Eclipse 是否有可能将旧文件缓存在某处?

回答by VonC

To complete CurtainDog's answer: from eclipse FAQ

完成 CurtainDog 的回答:来自eclipse FAQ

Every time you modify a file in Eclipse, a copy of the old contents is kept in the local history. At any time, you can compare or replace a file with any older version from the history.
Although this is no replacement for a real code repository, it can help you out when you change or delete a file by accident.
Local history also has an advantage that it wasn't really designed for: The history can also help you out when your workspace has a catastrophic problem or if you get disk errors that corrupt your workspace files.
As a last resort, you can manually browse the local history folder to find copies of the files you lost, which is a bit like using Google's cache to browse Web pages that no longer exist.

Each file revision is stored in a separate file with a random file name inside the history folder. The path of the history folder inside your workspace is

每次在 Eclipse 中修改文件时,都会在本地历史记录中保留一份旧内容的副本。您可以随时将文件与历史记录中的任何旧版本进行比较或替换。
虽然这不能替代真正的代码存储库,但它可以在您不小心更改或删除文件时为您提供帮助。
本地历史记录还有一个优点,它并不是真正为之设计的:当您的工作区出现灾难性问题或出现损坏工作区文件的磁盘错误时,历史记录还可以帮助您解决问题。
作为最后的手段,您可以手动浏览本地历史文件夹以查找丢失文件的副本,这有点像使用 Google 的缓存浏览不再存在的网页。

每个文件修订版都存储在一个单独的文件中,在历史文件夹中具有随机文件名。工作区中历史文件夹的路径是

.metadata/.plugins/org.eclipse.core.resources/.history/

You can use your operating system's search tool to locate the files you are looking for.

您可以使用操作系统的搜索工具来定位您要查找的文件。



Note, if your need to import your local history into a newworkspace, you will need both:

请注意,如果您需要将本地历史记录导入新的工作区,您将需要:

  • .metadata/.plugins/org.eclipse.core.resources/.history
  • .metadata/.plugins/org.eclipse.core.resources/.project
  • .metadata/.plugins/org.eclipse.core.resources/.history
  • .metadata/.plugins/org.eclipse.core.resources/.project

to have a functional local history in that new workspace.

在那个新工作区中拥有一个功能性的本地历史。

回答by Scott Stanchfield

Try right-clicking on the file in eclipse, and choose Replace With->Local History.

尝试在 Eclipse 中右键单击该文件,然后选择替换为->本地历史记录。

If there's history available, it'll show up as a list of edit times.

如果有可用的历史记录,它将显示为编辑时间列表。

But more importantly, as pointed out in other answers, be sure to put your files in version control! SVN is pretty easy to set up (you don't need a server; it can just use the file system); use it even if you aren't sharing with others.

但更重要的是,正如其他答案中所指出的,请务必将您的文件置于版本控制中!SVN 很容易设置(你不需要服务器;它可以只使用文件系统);即使您不与他人共享,也请使用它。

A tip: whenever you hear yourself say "yes!", check in all of your code. 10 minutes later, you'll be saying "how did I mess that up?"

提示:每当您听到自己说“是的!”时,请检查您的所有代码。10 分钟后,你会说“我怎么搞砸了?”

回答by chandima

If you have lost a full package structure due to accidental deletion or svn/cvs override, select the project> right click> Restore from local history => select the files.

如果由于意外删除或 svn/cvs 覆盖而丢失了完整的包结构,请选择项目 > 右键单击​​ > 从本地历史记录恢复 => 选择文件。

回答by 6006604

VonC's answer has all the information you need for finding the location of your code backups. I would simply add that if you are on a Mac or Linux, you can do something like this:

VonC 的答案包含查找代码备份位置所需的所有信息。我只想补充一点,如果您使用的是 Mac 或 Linux,您可以执行以下操作:

$ cd [WORKSPACE]/.metadata/.plugins/org.eclipse.core.resources/.history/
$ grep -rl "class Foo" . | xargs ls -lt

This will find all the versions of a file that contains a particular string (ie. "class Foo"), and sort them by date/time to easily find the most recent version.

这将找到包含特定字符串(即“class Foo”)的文件的所有版本,并按日期/时间对它们进行排序以轻松找到最新版本。

回答by CurtainDog

Open the CVS view and you should see a filter for local history. You should then be able to right-click on the correct version and Get Contents or do a manual compare and merge. I'm not sure what the eclipse defaults are for keeping local history but there is a decent chance you'll be able to get your stuff back if you act quickly.

打开 CVS 视图,您应该会看到一个本地历史过滤器。然后,您应该能够右键单击正确的版本并获取内容或进行手动比较和合并。我不确定 Eclipse 默认用于保留本地历史的内容是什么,但是如果您迅速采取行动,您很有可能能够取回您的东西。