Git - Mergetool

> Code - (Programming|Computer) Language > Code Versioning > Git

1 - About

The mergetool is a software that resolves a Git conflict.

Advertising

3 - Steps

3.1 - Installation

You need to install a mergetool such as:

  • tortoisemerge (tip: make a copy of tortoiseGitMerge), emerge, vimdiff (default)
  • meld, opendiff, kdiff3, tkdiff, xxdiff, gvimdiff, diffuse, ecmerge, p4merge, araxis

See git mergetool –tool-help for a full list

3.2 - Configuration

You can configure it

git config merge.tool tortoisemerge
git config merge.conflictstyle diff3
git config mergetool.prompt false
  • for meld
git config --global merge.tool meld
git config --global mergetool.meld.path "C:\Meld\Meld.exe"
git config --global merge.tool code

3.3 - Open

You can open it then with:

git mergetool

Example of output where mergetool is not configured but will still open tortoisemerge as I have it already installed on my computer thanks to TortoiseGit

This message is displayed because 'merge.tool' is not configured.
See 'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
tortoisemerge emerge vimdiff
Merging:
syntax.php

Normal merge conflict for 'syntax.php':
  {local}: modified file
  {remote}: modified file
Hit return to start merge resolution tool (tortoisemerge):
Advertising