Setting up custom merge tool in SourceTree

I can't seem to find the correct variables needed to set up a new custom merge tool. Can anyone point me to a list of variables that SourceTree makes available to custom merge tool commands?

..\..\semanticmergetool.exe -s=src.cs -b=base.cs -d=dst.cs -r=semanticmergetoolresult.cs -emt="..\..\mergetool.exe -b=""@basefile"" -bn=""@basesymbolic"" -s=""@sourcefile"" -sn=""@sourcesymbolic"" -d=""@destinationfile"" -dn=""@destinationsymbolic"" -r=""@output"" -t=""@filetype"" -i=""@comparationmethod"" -e=""@fileencoding""" -edt="..\..\mergetool.exe  -s=""@sourcefile"" -sn=""@sourcesymbolic"" -d=""@destinationfile"" -dn=""@destinationsymbolic"" -t=""@filetype"" -i=""@comparationmethod"" -e=""@fileencoding"""

This is the command that I would execute on the commandline. The 4 variables I need from SourceTree are sourcefile, basefile, destinationfile and resultfile.

2 answers

1 accepted

Hi Andrew,

The built-in SourceTree documents provide the help. Here's an extract:

Here is where you set the external diff/merge tools. SourceTree has in-built support for FileMerge, DiffMerge, Araxis Merge, KDiff3 and more, but if you wish to use another tool you can select 'Other' and provide your own tool information.

If you do choose to use 'Other', then you should supply the full path to the tool you wish to use in the 'Command' field, and the parameters that will be needed in the 'Arguments' field, with the following placeholders being available to supply file names:

  • $LOCAL - the name of the file on your local system
  • $REMOTE - the name of the file containing the other contents you're diffing or merging against
  • $BASE - in the case of a merge, the name of a file containing the common ancestor of $LOCAL and $REMOTE
  • $MERGED - the name of the file to save merge results to

Obviously 'Diff' only needs the first two parameters. For merges, you should really pick a tool which supports 3-way merging to make your life easier (all of the tools that SourceTree supports out of the box are capable of 3-way merging).

Hope that helps

Ah, no, the Windows version is yet to have the documentation integrated :)

Thank you very much. That's exactly what I was looking for.

On another note, I still can't seem to find the documentation anywhere. That's where I first tried to look. Maybe the windows version doesn't have built-in documentation yet?

I found this question on Google, as I was looking for the configuration for Semantic Merge Tool with SourceTree.

In case anyone else needs it, the External Diff Command arguments are: -d $LOCAL -s $REMOTE

The External Merge Command arguments are: -d $LOCAL -s $REMOTE -b $BASE -r $MERGED

I did the same thing. It took a second or two to realize that this was what I was looking for. I'm now running Semantic Merge with Source Tree, thanks to your answer.

Suggest an answer

Log in or Join to answer
Community showcase
Jason Wong
Published yesterday in Agility Beta

Welcome to agility

Every team in the world is unique, and so   Atlassian believes   that each and every team's best way of working  needs to  be molded to their unique circumstances  – ...

366 views 6 16
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot