How do I use Meld as a merge tool with Sourcetree on Windows?

后端 未结 5 1959
暗喜
暗喜 2021-01-31 09:04

I have the following in my .gitconfig file:

[user]
    name = myname
    email = myname@gmail.com
[core]
    autocrlf = true
    excludesfile = C:\\         


        
相关标签:
5条回答
  • 2021-01-31 09:24

    I feel the existing answers slightly missed the point. Here is my own dog food:

    Arguments Detail:

    Diff:  $LOCAL $REMOTE
    Merge: $LOCAL $BASE $REMOTE --auto-merge --output=$MERGED
    

    For External Diff, you need to remove $BASE from your argument list.

    For 3-way merging, you need to click on the External Merge Tool option instead, which will only be available if there are any unsolved conflicts.

    If you are not restricted to Sourcetree + Meld, I reckon the Git Extensions + KDiff3 suite could be a good open-sourced alternative also.

    0 讨论(0)
  • 2021-01-31 09:24

    The actual setting to use here in order to have a real 3-way merge, with read only THEIRS and MINE tabs is this:

    $LOCAL $BASE $REMOTE --auto-merge --output=$MERGED
    

    Note the = after --output.

    I've finally got this command right by digging in comments on the second answer to this question Git merging using Meld.

    0 讨论(0)
  • 2021-01-31 09:25

    Try adding the location of meld.exe to your PATH (e.g. C:\Program Files (x86)\Meld), and then in the Diff Command, just enter meld instead of the full path. See the gist How to use meld with Sourcetree on Windows.

    0 讨论(0)
  • 2021-01-31 09:28

    For OS X it looks like this:

    • Diff Command: /Applications/Meld.app/Contents/MacOS/meld.

      • Arguments: $LOCAL $REMOTE
    • Merge Command: /Applications/Meld.app/Contents/MacOS/meld.

      • Arguments: $LOCAL $BASE $REMOTE --auto-merge --output=$MERGED

    P.S. you might have to configure the order of $local and $ remote in meld prefrences as well..

    To use it from command line you have to install it via brew: brew install meld

    0 讨论(0)
  • 2021-01-31 09:39

    If you don't want to modify the PATH environment variable, you can use the DOS-compatible short names:

    C:\Progra~1 = C:\Program Files
    C:\Progra~2 = C:\Program Files (x86)
    

    That avoids the trouble-causing spaces in the path and plays nice with Sourcetree. It's hackish, but it works. You can then use something like this as the path to Meld:

    C:\Progra~1\Meld\meld.exe
    

    It may not be guaranteed that Progra~1 maps to the 64-bit directory, so you might need to experiment with which one maps to which.

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