git mergetool

External Tools

Resolve merge conflicts with a visual tool


The 'git mergetool' command opens each conflicted file in a merge tool (VS Code, Meld, KDiff3, vimdiff…) showing your version, their version and the common base side by side. You resolve the conflict in the tool, save, and git marks the file resolved. Configure your tool once with merge.tool.

Synopsis

git mergetool [--tool=<tool>] [-y] [<file>...]
[ ] optional| or<arg> placeholder... repeatable--flag option

Examples

Resolve every conflict

git mergetool

Opens each conflicted file in turn.


Set VS Code

git config --global merge.tool vscode

Use VS Code from now on.


Pick a tool once

git mergetool --tool=meld

Just this time.

Workflow Examples

1
git config --global merge.tool vscode

Choose the tool

2
git config --global mergetool.vscode.cmd "code --wait $MERGED"

Tell git how to start it

3
git mergetool

Use it

Troubleshooting

No merge tool configured

Cause: merge.tool is not set

git config --global merge.tool <name>, or git mergetool --tool-help

Tips & Pitfalls

Best Practices

  • ✓Configure one tool globally and learn its three-pane view.

Common Mistakes

  • ✗Leaving .orig backup files around — set mergetool.keepBackup false.

FAQ

A:

git mergetool --tool-help lists the ones installed and known to Git.