-->

Using OS X FileMerge/opendiff to view git differen

2019-09-14 01:35发布

问题:

We are version controlling our project using git. Developing under OS X, we'd like to use the FileMerge application distributed with the development tools to display git generated differences:
If we understood correctly, it is possible to configure its invocation through git difftool.


Following advices from different sources, we added this in our global git configuration file:

[diff]
    tool = opendiff

It works well for "file by file" diffs. But we prefer to have a directory difference loaded at once in the tool, for which the command is git difftool --dir-diff.

When invoking the directory diff command, the list of different files in correctly generated, but if we actually try to open one file, both sides show the error files does not exist. Apparently, this is because opendiff is terminating almost immediately, thus having git remove the temporary folders on which the comparison occurred.

Following this answer, we added those lines to our global git configuration file:

[difftool "opendiff"]
    cmd = /usr/bin/opendiff \"$LOCAL\" \"$REMOTE\" -merge \"$MERGED\" | cat

But it does not solve the file does not exist problem (and opendiff still returns almost immediately).

What would be the correct configuration for this use case ?

回答1:

The problem is Filemerge is filtering out the .git directory, which is where git is storing the directory used in the output of --dir-diff.

In Filemerge, go to Preferences > Filters and remove .git from Files to ignore and it should work.