- Developers who already know basic commit and branch actions
- Readers who want to understand command boundaries and risk
Command Reference
git-mergetool Tutorial
Explains how to use git-mergetool to launch an external merge tool for conflict resolution.
- A basic mental model of worktree, index, and commits
- Comfort reading `git status` and a small commit graph
- Using local cleanup commands on already shared history
- Continuing to rewrite before confirming a recovery path
The short version
git-mergetool is used to launch an external merge tool for conflict resolution.
When it is a good fit
- when you need to launch an external merge tool for conflict resolution
- when you want this step to be repeatable instead of ad hoc
- when you need a clearer mental model of what Git is recording or updating
Basic example
git mergetool
What to watch most closely
Advanced commands are not always part of the daily path, but mistakes with them usually cost more to recover from.
A safer working habit
Rehearse the flow on a small reproducible history before running it in a production repository.
Useful angles for understanding it
- Handle more complex collaboration or history-analysis tasks
- Turn one-off steps into repeatable routines
- Reduce the risk of advanced operations
Related reading
Read it alongside git status, git log, and git show so it is easier to see how the command changes history, refs, the index, or the working tree.
What problem this command solves in a workflow
git mergetool is a conflict-resolution assistant that launches an external merge tool (vimdiff, meld, kdiff3, Beyond Compare, etc.) to help you resolve merge conflicts. It does not automatically fix conflicts — it presents the conflicting files with three views (base, local, remote) in a visual interface, making it easier to combine changes correctly than editing conflict markers by hand. After you save the resolved file in the tool, git mergetool stages the result.
Typical use cases
- Resolving merge conflicts during
git merge,git rebase, orgit cherry-pickwhen multiple files have overlapping changes. - Using a visual diff tool to understand complex three-way merges where conflict markers alone are hard to reason about.
- Standardizing conflict resolution across a team by configuring a shared mergetool (e.g.,
git config merge.tool meld). - Working through a rebase with many conflicts one file at a time, with the tool handling the staging automatically.
Diagram view
Special cases and boundaries
- The external tool must be installed and configured. Run
git mergetool --tool-helpto see available options, then setmerge.toolin your config. - Backup files (
.orig) may be left behind after resolution. Usemergetool.keepBackup = falseto suppress them if you don't need them. - Mergetool only handles files with active conflict markers. Clean files (already resolved or conflict-free) are skipped.
- After all conflicts are resolved, you must still complete the operation — run
git commit(for merge) orgit rebase --continue(for rebase). - Mergetool modifies the working tree and index as you save resolved files. Unlike the read-only tools above, it does change repository state — but only within the scope of the ongoing merge/rebase operation.
- If the external tool crashes or you close it without saving, the conflict markers remain and you can re-run mergetool.