git mergetool
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>...]Examples
Resolve every conflict
git mergetoolOpens each conflicted file in turn.
Set VS Code
git config --global merge.tool vscodeUse VS Code from now on.
Pick a tool once
git mergetool --tool=meldJust this time.
Workflow Examples
git config --global merge.tool vscodeChoose the tool
git config --global mergetool.vscode.cmd "code --wait $MERGED"Tell git how to start it
git mergetoolUse 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
git mergetool --tool-help lists the ones installed and known to Git.