Restore Deleted Files in Eclipse with Local History

I’m using Version Control Systems like Git and SVN on a daily base. Because this gives me the opportunity to revert my changes and go back in time in my project. A VCS is incredible useful as well if I have deleted files or settings: restoring it is just a matter of a few mouse clicks.

But even without using a VCS, Eclipse has a built-in simple version control system: the Local History.

Eclipse History View

Eclipse History View

I touched on the Local history already in earlier posts, as in Eclipse Local History & Quick Diff or Compare and Merge with Eclipse.

Restore from Local History

If I delete a file or folder from my project, I get this dialog:

Delete Resources Dialog

Delete Resources Dialog

That file does not go into the normal Windows Recycle Bin. Instead, Eclipse has its own recycle bin, called the local history. To restore a deleted file, I use the context menu on a project folder and select ‘Restore from Local History…’:

Restore from local history

Restore from local history

This opens a dialog where I can select what exactly I want to restore:

Restore from Local History Details

Restore from Local History Details

💡 The Local History is not only useful to restore files: it can restore any changes or edits in a resource too.

Local History Configuration

Unlike a full VCS, the capability of the Local History is limited to size of it. The size of the local history is configured under the menu Window > Preferences > General > Workspace > Local History:

Local History Preferences

Local History Preferences

💡 The local history can get rather large, depending on the settings. If you want to have a look, then see the .metadata\.plugins\org.eclipse.core.resources folder inside your workspace which can grow up to several hundreds of MBytes. And if the local history is too big, this might slow down the exit of Eclipse, as Eclipse is compacting that information at that time.

What is not covered

The local history is stored based on the project, and the ‘Restore’ operation needs to be performed on the project folder. So this means: if you delete the project itself, you really loose it:

Deleting Eclipse Project

Deleting Eclipse Project

So you have been warned 🙂

Summary

Undoing changes in Eclipse with the Local History is incredible useful. I just need to keep in mind that this does not work for deletion of a whole project, and that I need to keep an eye on the size of the history for performance reasons. But with the typical settings to have a history for a few days, that works very well.

Happy Restoring 🙂

6 thoughts on “Restore Deleted Files in Eclipse with Local History

    • Is the problem that files does not show up in the Projects view, but they are still on disk?
      And as you have backups, can you go back to a previous version to see what the differences are?

      Like

  1. Hello Erich,

    I have learned a lot from your articles (mostly relating to NXP boards) – but today you saved my day! Thank you very much!1

    Liked by 1 person

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.