gitbeyondcomparedifftool

git difftool is not working as configured in .gitconfig


I am using Beyond Compare as my external diff tool. It does not work when I configure it on my new computer in the .gitconfig as I did on other computers. If I specify the extcmd with too many quotes then it does work.

One big difference between now and previous times is that I am using LFS on my new repository.

.gitconfig file:

[diff]
    tool = bc4
    renameLimit = 999999
[difftool]
    prompt = false
[difftool "bc4"]
    cmd = 'C:/Program Files/Beyond Compare 4/BComp.exe' \"$LOCAL\" \"$REMOTE\"

Does not work (with either single or double quotes):

$ git difftool --extcmd='C:/Program Files/Beyond Compare 4/BComp.exe' HEAD
C:/Program Files/Git/mingw64/libexec/git-core\git-difftool--helper: line 62: C:/Program: No such file or directory
fatal: external diff died, stopping at file.cs

Does work:

git difftool --extcmd="'C:/Program Files/Beyond Compare 4/BComp.exe'" HEAD
  1. How can I get it to work so that I can just use git difftool HEAD?

  2. Is Git LFS causing my problems?

  3. Is something else misconfigured on my new computer and that is causing my problems?

I tried changing the single quotes (') in the config to double-quotes (") but that also did not work.

I am using git version 2.29.2.windows.2 on a fresh install of Windows 10.

Edit: forgot to be clear on what "does not work" means: It does not open Beyond Compare, but there is no error message. It just seems to do nothing for several seconds:

$ git difftool HEAD

$

My entire .gitconfig (in case it helps): https://hastebin.com/icuduxecen.ini


Solution

  • Unless you have a specific reason to specify the full command line to invoke Beyond Compare, specify just the path to the program:

    [difftool "bc4"]
        path = "C:/Program Files/Beyond Compare 4/BComp.exe"
    

    Note the double-quotes and forward slashes.

    Edit: Be sure to remove the line cmd = (or rename it cmd to xcmdx or something to hide it if you do not want to remove it).