git - set KDiff3 as default mergetool

Vahid Najafi picture Vahid Najafi · Mar 5, 2017 · Viewed 11.1k times · Source

After installing KDiff3 for managing conflicts in git, still the default one is opening for me:

enter image description here

Here is the configuration that mentioned in this answer:

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

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

NOTE: I can be able to run KDiff3 individually with simple files, but I can't run it in my git project. Any idea?

Edit: Here is my .gitconfig :

[user]
    email = [email protected]
    name = vahid najafi
[diff]
    tool = kdiff3
    guitool = kdiff3
[merge]
    tool = diffmerge
    tool = kdiff3
    tool = kdiff3
[mergetool "diffmerge"]
    trustExitCode = true
[mergetool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    trustExitCode = false
[difftool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    trustExitCode = false

Answer

Vahid Najafi picture Vahid Najafi · Mar 6, 2017

Finally I made another solution! I used meld instead of kdiff3. First download meld from here. Then change config for meld in c:/Users/yourName/.gitconfig :

[user]
    email = [email protected]
    name = vahid najafi
[diff]
    tool = meld
[difftool "meld"]
    path = C:/Program Files (x86)/Meld/meld/meld.exe
[difftool]
    prompt = false
[merge]
    tool = meld
[mergetool "meld"]
    path = C:/Program Files (x86)/Meld/meld/meld.exe
[mergetool]
    keepBackup = false

NOTE: Try to use git cmd instead of windows cmd. When you have conflict, just run : git mergetool. For more detail and example, see here.