Search code examples
giteclipseegit

eGit "Compare With" & "Replace With" Options


Can someone please explain the difference between the seven options in eGit for "Replace With/Compare With" (e.g., Local History, Head Revision, etc.)?

enter image description here


Solution

  • I think you're not asking what the difference is between "compare" and "replace", but the differences between the options that you see in the "Replace With" menu. Under that assumption, I'll describe a bit about each of those.

    • Local History...

    When you edit files in Eclipse and save changes to your local workspace, Eclipse saves each of those file contents in its "local history". These are just saved on your local disk, not even in your local git repository. When you select this option, you can select an entry in that local history to compare against or replace with.

    • Previous from Local History

    This just goes to your local history, where the top entry is your current file contents, and uses the next to the top entry to compare against or replace with.

    • HEAD revision

    This goes to your git local repository and uses the file contents defined by the HEAD revision on your current branch, to compare against or replace with.

    • Index

    The git "index", as you can read on the internet, is a staging area between your git workspace and your repository. If you have a copy of the current file in the index, which means you were preparing to commit it, then this will use that file content.

    • Previous Revision

    This will go to your local git repository and use the commit previous to the HEAD revision to compare against or replace with.

    • Branch, Tag, or Reference...

    This presents a dialog where you can select a branch in your local or remote repository (which will use the HEAD revision on that branch for the file content), or a tag, or a "reference" (I can't say much about that).

    • Commit...

    This just presents a dialog with the previous commits on the current branch, latest first, allowing you to select one to get the file content.