Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have the following in my .gitconfig file:

[user]     name = myname     email = [email protected] [core]     autocrlf = true     excludesfile = C:\\Users\\myname\\Documents\\gitignore_global.txt [diff]         tool = meld [difftool "meld"]         cmd = "C:/Program Files (x86)/Meld/meld/meld.exe"         prompt = false [merge]         tool = meld  [mergetool "meld"]         cmd = "C:/Program Files (x86)/Meld/meld/meld.exe" [difftool "sourcetree"]     cmd = "C:/Program Files (x86)/Meld/meld/meld.exe $PWD/$LOCAL $PWD/$BASE $PWD/$REMOTE" [mergetool "sourcetree"]     cmd = 'C:/Program Files (x86)/Meld/meld/meld.exe' \"$LOCAL\" \"$REMOTE\" \"$MERGED\"     trustExitCode = true 

And in Sourcetree, I have the following settings:

Enter image description here

However, when I right-clicked a file on Sourcetree to do an external diff, I was able to open Meld, but the contents of the file were not displayed at all.

Enter image description here

What have I done wrong in the settings?

like image 604
mynameisJEFF Avatar asked Feb 16 '15 13:02

mynameisJEFF


People also ask

How do I set the merge tool in SourceTree?

SourceTree config First, open up the options window and go to Diff tab. Change both External Diff Tool and Merge Tool to Custom. In the Diff Command field enter the full path to the vsdiffmerge.exe. For VS 2015 and below you can find it in the Visual Studio installation folder, under Common7\IDE subfolder.


2 Answers

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

Enter image description here

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.

Context menu of External Merge Tool

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

like image 156
Paris Qian Sen Avatar answered Sep 24 '22 12:09

Paris Qian Sen


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.

like image 23
Jozef Legény Avatar answered Sep 25 '22 12:09

Jozef Legény