How can I configure KDiff3 as a merge tool and diff tool for git? Ask Question

How can I configure KDiff3 as a merge tool and diff tool for git? Ask Question

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 can I configure it to use it as a diff tool?

ベストアンサー1

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/bin/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/bin/kdiff3.exe"
git config --global difftool.kdiff3.trustExitCode false

Note that the latest version kdiff3 moved the executable from the root of the application folder C:/Program Files/KDiff3 into the bin/ folder inside the application folder. If you're using an older version, remove "bin/" from the paths above.

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

git-difftool は、各ファイルに対して個別に diff ツールを呼び出します。デフォルトでは、diff ツールによって報告されたエラーは無視されます。呼び出された diff ツールがゼロ以外の終了コードを返したときにgit-difftoolを終了するには、--trust-exit-codeを使用します。

おすすめ記事