How to setup external difftool for windows 10

71 Views Asked by At

I am trying to setup an external difftool, I've read many pages but no one has provided a solution that works, or they leave out information.

I have gotten to where the program opens but only one file is showing, the other is missing. I used the "Diffinity" program (which I downloaded, and added to ENV variables)

Then in C:\Users\myuser\.gitconfig I had:

[diff]
    tool = Diffinity
[difftool "Diffinity"]
    cmd = 'C:/Program Files/Diffinity/Diffinity.exe' "$LOCAL" "$REMOTE"

When trying it:

git difftool c8995eb 6235431

the program opens and one of the files is showing to the right, but the other gives an error "failed to open \\.\nul".

I also tried another difftool, "diffmerge" which has instructions to configure the difftool, but it doesn't work and results in "cannot stat file".

I've also looked at a page on git-scm.com which talks about creating a script to pass in arguments, in addition to the .gitconfig stuff but it may be for mac and very vaguely described. So is an extra shell script needed? And how to configure it for windows.

1

There are 1 best solutions below

1
On

It seems like the issue you are encountering is related to the way the command in your .gitconfig file is specifying the paths to the files that are being compared. The "$LOCAL" and "$REMOTE" variables are not being expanded correctly, resulting in the error "failed to open .\nul".

One potential solution could be to use the full path to the files that are being compared, rather than relying on the "$LOCAL" and "$REMOTE" variables. For example:

[difftool "Diffinity"]
cmd = 'C:/Program Files/Diffinity/Diffinity.exe' "C:\path\to\local\file" "C:\path\to\remote\file"

Alternatively, you could try using the git command line options to specify the path to the files you want to compare, when you run the difftool:

git difftool --tool=Diffinity --dir-diff --path=path/to/local/file c8995eb path/to/remote/file 6235431

As for the second difftool, "diffmerge", it seems like the issue you're encountering is also related to specifying the correct path to the files. Make sure that the path you're specifying in the command is correct and that the files exist in that location.

It is not necessary to have an extra shell script on Windows and the instructions on git-scm.com are for all OS, but it's important to understand that the command you need to run may differ depending on your specific setup and the difftool you're using.