Git Diff and Meld on Windows

后端 未结 5 1232
闹比i
闹比i 2020-12-13 21:03

Has anyone ever made Meld work with Git on Windows? I am trying to make it work and I have no success.

I have Meld installed and when I call it from the command lin

相关标签:
5条回答
  • 2020-12-13 21:08

    Usually, you can find an example on Windows similar to this gist, with meld.exe being in your PATH):

    git config --global merge.tool meld
    git config --global mergetool.meld.cmd 'meld.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"'
    
    git config --global diff.tool meld
    git config --global difftool.meld.cmd 'meld.exe \"$LOCAL\" \"$REMOTE\"'
    

    You can find more robust settings in "Git mergetool with Meld on Windows", but the idea remains the same.


    The OP reports in the comments:

    For the difftool, your commands write the following configurations in .gitconfig:

    [diff]
      tool = meld
    [difftool "meld"]
      cmd = meld.exe \\\"$LOCAL\\\" \\\"$REMOTE\\\"
    

    I changed them to:

    [diff]
      tool = meld
    [difftool "meld"]
      cmd = meld.exe $LOCAL $REMOTE
    

    and everything worked fine.

    0 讨论(0)
  • 2020-12-13 21:09

    Another tip for users invoking diff from gitk (by right-clicking the context menu item "External Diff"):

    The above settings may get overridden by gitk's preferences. In that case, change the tools in gitk's menu EditPreferencesGeneralExternal diff setting.

    0 讨论(0)
  • 2020-12-13 21:19

    For Windows 7 (or even other versions of windows), add these lines in the .gitconfig file.

    [diff]
        tool = meld
    [merge]
        tool = meld
    [difftool "meld"]
        path = C:/Program Files (x86)/Meld/meld.exe
    [mergetool "meld"]
        path = C:/Program Files (x86)/Meld/meld.exe
    

    Note that there is no need to use " for the path even if it includes spaces. Just remember to use forward slashes instead of backward slashes.

    0 讨论(0)
  • 2020-12-13 21:22

    Or even better, if you're on a locked-down system where fooling with the path is not allowed or you just don't want to pollute your path space, you can just put in the full path to Meld.

    I also prefer my current working code copy to show up on the left, so I swapped the $REMOTE and $LOCAL arguments. Also mind the conversions of \ to / and don't for get to escape the double quotes.

    [diff]
        tool = meld
    [difftool "meld"]
        cmd = \"C:/Program Files (x86)/Meld/meld/meld.exe\" $REMOTE $LOCAL
    
    0 讨论(0)
  • 2020-12-13 21:25

    I tried several variations of trying to set the path with git config to no avail. Since I want to use Meld from the Git Bash console window, what did work was to export the path to the Meld directory, restart the Bash shell and lo & behold git difftool --tool-help and git mergetool --tool-help now recognize Meld, and I can choose it as my preferred tool.

    .profile

    export PATH=/c/Program\ Files\ \(x86\)/Meld/:$PATH
    

    .gitconfig

    [merge]
        tool = meld
    [diff]
        tool = meld
    
    0 讨论(0)
提交回复
热议问题