Recently I was using GitExtension 2.46, but the Git version that has the same is 1.9.4.msysgit.2. Willing to use only Git commands, I uninstalled GitExtension and install the latest version available of Git and KDiff3.

When I make a merge and have conflicts, I run the following command:

$ git mergetool

Then I receive the message:

The merge tool kdiff3 is not available as 'kdiff3'.

I guess it must be by the KDiff3 path.

Environment

OS: Windows 10

Git 2.6.1.windows.1

KDiff3 0.9.98 (64 bit)

Questions:

What do I have to configure in the .gitconfig file for the command $ git mergetool to open the KDiff3 GUI with the versions LOCAL, REMOTE, BASE and MERGED of conflicted file?

The use of the trustExitCode option depends on what you want to do when diff tool returns. From documentation:

git-difftool invokes a diff tool individually on each file. Errors reported by the diff tool are ignored by default. Use --trust-exit-code to make git-difftool exit when an invoked diff tool returns a non-zero exit code.

Still, why would I want git-difftool not to exit if kdiff3 fails?
– David TorresFeb 16 '17 at 16:21

7

For me to have the diff tool recognized by Visual Studio 2015, I had to change this line git config --global --add diff.guitool kdiff3 to this : git config --global --add diff.tool kdiff3
– Guillaume RaymondApr 11 '17 at 2:42

According to the referenced docs setting trustExitCode to false is unnecessary, since the default is to ignore it anyway.
– matt wilkieOct 26 '17 at 15:57

4

AFAIK, --add will add a second or third entry when invoked multiple times. That's hard to fix later, because it can't simply be removed with --remove. Just setting a value without --add should be ok.
– Thomas WellerMar 6 '18 at 13:48

Why do you suggest not to trust exit code?
– Alex78191May 6 '17 at 7:27

@Alex78191, my answer reflects the Joseph's answer and there you can find more details about this setting.
– Igor KustovMay 7 '17 at 17:19

4

It took me a long time to get this right. 2 things led me astray: (1) The .gitconfig file I was editing was not the one being used. See stackoverflow.com/questions/2114111/… for identifying the one(s) being loaded. (2) Don't mix and match cmd = and path = in gitconfig, TL;DR: delete cmd and just use path
– matt wilkieOct 26 '17 at 18:47

1

Now on git bash use .... git difftool <filename> or simple git difftool to run the diff gui kdiff3 you just set.
– VibrantVivekJan 8 '18 at 16:13

Don't use --add since that may result in 2 config entries if you run the command twice. It's a mess cleaning this up, because you can't delete a single entry any more. See git-scm.com/docs/git-config: "Multiple lines can be added to an option"
– Thomas WellerMar 27 at 10:27

In a typical Unix installation all executables reside in several well-known locations (/bin/, /usr/bin/, /usr/local/bin/, etc.), and one can invoke a program by simply typing its name in a shell processor (e.g. cmd.exe :) ).

In Microsoft Windows, programs are usually installed in dedicated paths so you can't simply type kdiff3 in a cmd session and get KDiff3 running.

The hard solution: you should tell Git where to find KDiff3 by specifying the full path to kdiff3.exe. Unfortunately, Git doesn't like spaces in the path specification in its config, so the last time I needed this, I ended up with those ancient "C:\Progra~1...\kdiff3.exe" as if it was late 1990s :)

The simple solution: Edit your computer settings and include the directory with kdiff3.exe in %PATH%. Then test if you can invoke it from cmd.exe by its name and then run Git.

(When trying to find out how to use kdiff3 from WSL git I ended up here and got the final pieces, so I'll post my solution for anyone else also stumbling in here while trying to find that answer)

How to use kdiff3 as diff/merge tool for WSL git

Steps for using kdiff3 installed on Windows 10 as diff/merge tool for git in WSL:

Add the kdiff3 installation directory to the Windows Path.

Add TMP to the WSLENV Windows environment variable (WSLENV=TMP/up). The TMP dir will be used by git for temporary files, like previous revisions of files, so the path must be on the windows filesystem for this to work.