Eclipse is very workspace centric: it only knows and deals with files in the workspace. So it is easy to compare and merge files present in the workspace: I select both files/folders and compare them with each other:
But what if the files and folders are NOT in the workspace?
Hidden Option to Compare External Files
As outlined in this post, it needs a special plugin to search for files outside the Eclipse workspace. And doing a file or folder compare outside of the workspace requires a trick as shown in this post.
Thanks to a tip from John there is another (hidden) way in Eclipse to compare external files
The trick is described in this article and requires a keyboard shortcut assigned.
Select the menu Window > Preferences > General > Keys and assign a shortcut key for ‘Compare with Other Resource‘:
(I’m using Ctrl+Shift+Home above).
To compare, I have first to select a file, folder or project, then I press my shortcut. Then the following dialog shows up (with the selection as default):
If the dialog does not show up, then I probably have not selected a file or folder in the Eclipse project view.
Now I can select the external files or folders to compare with:
With this, I can now compare and merge my files and folders with the Eclipse Compare view:
I can select two files/folders and then press the shortcut, and it will populate the search dialog values.
Drag & Drop
That compare dialog has a nice feature: I can drag&drop files and folders too:
With ‘Compare with Other Resource‘ I have a way to compare files/folders, and I’m not limited to the workspace files. The only disadvantage is that I need to assign a shortcut for it first. Beside of that: yet another hidden treasure in Eclipse .