Git mergetool with Meld on Windows

前端 未结 9 991
名媛妹妹
名媛妹妹 2020-12-02 05:19

In Linux, my favorite merge tool is Meld, and I\'ve had no problems using or configuring it to work with Git. However, in Windows it has been a different story.

Fir

相关标签:
9条回答
  • 2020-12-02 06:11

    Windows:

    You can use these two commands (as Arugin says)--using the proper path to Meld.exe:

    git config --global merge.tool meld
    git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
    

    OR you can just edit your C:\Users\YOUR_USER_NAME\.gitconfig file directly and add the following to the end of it:

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

    Now call git difftool in Git Bash for Windows and Meld will open up as your default difftool viewer.


    Linux:

    UPDATE 20 Sept. 2019:
    - I might as well put the Linux version here too for my own reference in one place if nothing else:

    For Linux it's super easy too:

    sudo apt update
    sudo apt install meld
    gedit ~/.gitconfig  # edit your ~/.gitconfig file (gedit GUI editor will open)
    

    Then add to the bottom of the .gitconfig file:

    [diff]
        tool = meld
    

    That's it! git difftool now works on Linux Ubuntu!

    Related:

    1. Download and install meld from here: https://meldmerge.org/
    2. How do I make Git use the editor of my choice for commits?
    3. https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles
    0 讨论(0)
  • 2020-12-02 06:18

    After trying all of the above, setting Meld to run as administrator worked for me.

    1. Right-click Meld.exe
    2. Go to Properties > Compatibility and select the Run this program as an administrator checkbox

    The errors I received referenced temp files like c:\windows\temp\meld-*, which were not being created. Elevating Meld's permissions seems to do the trick as it now works with both git difftool and running manually within Meld.

    0 讨论(0)
  • 2020-12-02 06:19

    I found a solution in a bug report on the meld installer, on this page:

    https://code.google.com/p/meld-installer/issues/detail?id=11

    As far as I understand, the problem is that the meld.exe program (which runs meld through the python interpreter) needlessly sets the command's working directory to that of meld.exe. This causes relative paths to be interpreted incorrectly when passed as command line arguments.

    The solution is to replace the provided meld.exe with one generated by compiling the meld.ahk file, using AHK2EXe (AutoHotKey script -> exe). Just download the script furthest down the page, as there have been a few version posted there.

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