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.
Restore from Local History
If I delete a file or folder from my project, I get this 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…’:
This opens a dialog where I can select what exactly I want to restore:
💡 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:
💡 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:
So you have been warned 🙂
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 🙂