git - set KDiff3 as default mergetool

后端 未结 2 1936
终归单人心
终归单人心 2021-01-14 16:05

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

Here is the configuration that men

相关标签:
2条回答
  • 2021-01-14 16:39

    I do not know kdiff3, but you might need to add the files you want to compare to your tool call as parameters (see command line options for KDiff3 call here). In your global config (accessible via git config --global -e), the respective lines should look something like this:

    [merge]
        tool = kdiff3
    [mergetool "kdiff3"]
        trustExitCode = false
        cmd = 'C:/Program Files/KDiff3/kdiff3.exe' "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
    

    Since I did not try this with KDiff3, you might have to switch the order of "$LOCAL" "$BASE" "$REMOTE"and "$MERGED" variables, but this post sould provide enough additional more information on this. Although it's about the Meld tool, I'm pretty sure the handling is analogical, and there are some pretty good and informative answers.

    EDIT: Assuming you use windows: You can just locate it in Windows explorer, usually in c:\user\yourusername\.gitconfig, and open it with any editor. In Linux, see this post. Then, replace all the merge, mergetooland difftool sections with the following:

    [merge]
        tool = kdiff3
    [mergetool "kdiff3"]
        cmd = "C:/Program Files/KDiff3/kdiff3.exe" "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
        trustExitCode = false
    [difftool "kdiff3"]
        cmd = "C:/Program Files/KDiff3/kdiff3.exe" "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
        trustExitCode = false
    

    If ot does not work, it is possible that you have to change the order of "$LOCAL" "$BASE" "$REMOTE"and "$MERGED" variables or remove one of them. You can find sufficient information about this in the links provided above.

    0 讨论(0)
  • 2021-01-14 16:52

    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 = vahid.vdn@gmail.com
        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.

    0 讨论(0)
提交回复
热议问题