AndyJarrett

Going beyond Eclipse's local file compare/replace

Originally I wanted to title this "Last night Eclipse saved my life" but decided that didn't really explain this mini guide all to well.

First off, if you are not on Eclipse than you probably don't know about two great features, "Compare with local history", and "Replace with local history". In brief, Eclipse saves all previous version of your file(s) you are working on. So with a simple click you can "Compare"/"Replace" your current version of a document to the original one you started working on 2 days ago! Think of it as a mini source control without the checking in.out. If you want to know more about these features go to Robert Blackburn write up in Fusion Authority.

What does "Going beyond Eclipse's local file compare/replace" mean then?

Let go back to the other night. Working with a set of XML documents in Eclipse and not thinking what I did I managed to delete all the files that I had been working on and worst still, they were not to be found in the recycle bin - lost forever in oblivion. Now, imagine if this happened 3 or 4 days ago and you didn't realise at the time! This is were Eclipse's next cool feature comes into play, "Restore from local history".

To restore a version of a deleted file:

  1. In the navigation view, right click the folder/project that your need to examin.
  2. From thepop-up menu, select "Restore from Local History...".
  3. At this point the "Local History" window opens showing all the files and folders that have been created within this project/folder. See the image below
  4. From first left hand panel, "Available Files In Local History", highlight/check the file(s) you want to restore.
  5. Once you've highlighted/checked your file the right hand side panel, "Local History of 'xx.xx'" will be populated and display a list of available versions.
  6. You can check multiple files to restore.
  7. You don't always have to use the right hand side panel. If you just want the last state of the file then just use the check box as it defaults to the last save.
  8. Once all done simply click Restore
Restore local history

In Eclipse you can specify how many days to keep files, how many entries per file, or the maximum file size for files. To do this go to Window » Preferences » General » Local History.