Search code examples
gitgit-indexgit-difftool

What are the "lindex", "rindex" and "wtindex" files generated by git difftool?


When I run:

git difftool -d

It creates a temporary directory containing the files to be shown in the diff. The structure looks like this:

tmpdir/
  left/
    file1
  lindex
  right/
    file1
  rindex

The "left" and "right" directories are clear. But what are the "lindex" and "rindex" files? What do they contain? How can I view them? Sometimes there's no "rindex" but a "wtindex" file instead.


Solution

  • They represent indexes, generated by git update-index in git-difftool.perl#L224-L248.

    • lindex represents LOCAL: A temporary file containing the contents of the file on the current branch.
    • rindex represents REMOTE: A temporary file containing the contents of the file to be merged.
    • wtindex represented MERGED (working tree): the result of the merge in progress

    Those indexes are updated using --index-info in order to facilitate the diff between any locale modification you will be doing for each file, and the three versions mentioned above.