Launch External Merge Tool For Sourcetree

In this tutorial, I want you to practice using the MergeTool approach. To start it, you can execute the command git mergetool or, in SourceTree, you can right click on each file that has a merge conflict, Resolve Conflicts - Launch External Merge Tool. This should now open up your external merge tool (i.e. In Sourcetree, go to Tools Options. Go to the Diff tab. In the External Diff/Merge section, configure the settings as follows: External Diff Tool - Select Custom. Diff Command - Enter the path of the Oxygen diffFile.exe file (for example: c: Programs Oxygen XML Editor 19 diffFiles.exe).

  • Status:Needs Triage(View Workflow)
  • Resolution: Unresolved
  • Fix Version/s: None
  • Labels:
  • Environment:

    Windows 10: 1803

    Git: 2.22.0.windows.1

    Helix P4Merge: P4Merge/NTX64/2019.1/1815056

Sourcetree lists P4Merge as a merge tool available to use (under Options -> Diff).

However, after setting the merge tool to P4Merge, and then setting the merge command to the filepath for P4Merge.exe, I am still unable to resolve conflicts by using Context Menu -> Resolve Conflicts -> Launch External Merge Tool.

The 'Visual merge in progress' dialog opens for a moment, and the *Base, *Local *Remote etc. files are created for a moment, but then the dialog closes and the files disappear. P4Merge never opens.

Tool

When setting the Merge Command for P4Merge under Options -> Diff, I've tried using both the full filepath of P4Merge.exe without double quotes and the full filepath of P4Merge.exe with double quotes, and neither work.

Votes:
2Vote for this issue
Watchers:
3Start watching this issue

Launch External Merge Tool Sourcetree Mac

Estimated:
1h
Remaining:
1h
Logged:
Not Specified

In this article we will learn to configure external diff and merge tools for git difftool and git mergetool commands. External tools can make developer’s life easy, to compare changes before committing or resolving conflicts.

1) Supported external tools

There are many tools git supports, you can check with following command.

2) Configure diff and merge tool

In this article we will configure winmerge as diff and merge tool in git but you can configure any other tool with same way.
Before we start, make sure you have winmerge installed on your machine, you can download from here.

MergeLaunch external merge tool sourcetree

Launch External Merge Tool Sourcetree

2.a) Git Bash

You can configure external diff and merge tool by git bash commands as show below.

After executing these commands you can use git difftool or git mergetool commands to open winmerge.

2.b) .gitconfig File

You can configure git external diff and merge tool by directly updating .gitconfig file as well.
Add following entries in the configuration file.

Launch

For windows users .gitconfig file is under C:UsersKheri.gitconfig

3) Additional Parameters

3.a) prompt

If you notice in above example, we specifically updated prompt = false with following command.

By default, every time you run git difftool command, git bash ask if you really want to launch external tool ? ( shown in below snippet). It might not be pleasant for most of developers. You can disable it setting it false.

3.b) trustExitCode

If your merge tool can indicate that a merge conflict is resolved successfully with its exit code, you can set trustExitCode to true, as below:

Sourcetree Launch External Merge Tool Disabled

Otherwise, you will be prompted to indicate whether the merge conflict is resolved or not.

3.c) keepBackup

While resolving conflicts, mergetool creates backup files (with extension *.orig). These files can be removed safely, once the merge session is completed. If you want to automatically remove these files after the conflicts are resolved successfully, set the keepBackup flag to false as below:

4) Conclusion

In this short article we learned how to configure external tool for diff and merge.

References :

  • Java Default Methods Tutorial -
  • Java Optional orElseThrow() Example -
  • Java Optional ifPresent() Example -