Git: How configure KDiff3 as merge tool and diff tool

Joseph picture Joseph · Oct 23, 2015 · Viewed 182.1k times · Source

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?

  • How configure it to use it has diff-tool?

Answer

Joseph picture Joseph · Oct 26, 2015

These sites were very helpful, almost, mergetool and difftool. I used the global configuration, but can be used by repository without problems. You just need to execute the following commands:

git config --global merge.tool kdiff3
git config --global mergetool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global mergetool.kdiff3.trustExitCode false

git config --global diff.guitool kdiff3
git config --global difftool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global difftool.kdiff3.trustExitCode false

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.