It is possible to compare and integrate changes between two versions of a file using Eclipse’s built-in “Compare” capability.

In a version control system, this function can be used to compare and integrate changes made to the code in several iterations of a file, as well as between separate files.

You can use Eclipse’s Compare function in one of two ways:

A file can be compared to others by right-clicking it in the Project Explorer or Package Explorer and selecting “Compare With” -> “Each Other” or “Another Branch” or “Another Version” or “Another Local History.”

  • Simply press CTRL+D after selecting two files or resources in the Project Explorer or Package Explorer.
    Use the menu options “File” > “Compare With” > “Each Other” / “Another Branch” / “Another Version” / “Another Local History” / “Each Other”
  • As soon as you select the Compare option, Eclipse will create a new window in which you can see the two documents side by side, with the differences highlighted. You can compare the two versions and decide whether or not to combine them.

As an added bonus, the Compare tool is compatible with a wide range of VCSes, including Git, SVN, etc., provided you have the appropriate plugin installed.

When working on large projects with several developers or when using a version control system, this capability can be extremely helpful for reviewing and merging code changes. You may find that you are able to accomplish more in less time using Eclipse.

Categorized in:

Tagged in: