Setting up and using Meld as your Git difftool and mergetool
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Meld is a graphical diff and merge tool that pairs well with Git when command-line diff output is too dense or when merge conflicts need side-by-side inspection. Git does not care which GUI tool you use, as long as you tell it how to launch that tool for diff and merge operations.
The setup has two parts: install Meld so it is runnable from the shell, then configure Git to invoke it as difftool and mergetool.
Basic Git Configuration
If meld is already on your PATH, the simplest global configuration is:
This tells Git:
- use Meld when
git difftoolis called - use Meld when
git mergetoolis called - trust Meld's exit code during merges
- skip the per-file confirmation prompt for diffs
You can confirm the values with:
When Meld Is Not on PATH
On some systems, especially Windows or custom Linux installs, Git cannot find the meld executable automatically. In that case, define the command explicitly.
Git substitutes those environment variables when it launches the tool:
- '
LOCALis your version' - '
REMOTEis the other version' - '
BASEis the common ancestor during merges' - '
MERGEDis the file Git expects you to save'
The exact pane layout may vary by Meld version, but those paths are the core integration points.
Using Meld for Diffs
After configuration, use:
or for a specific file:
This is especially useful when reviewing unstaged or staged changes:
Because git diff and git difftool look at the same underlying Git objects, you can switch between text and GUI review without changing your workflow.
Using Meld for Merge Conflicts
When a merge or rebase stops on conflicts, launch:
Git opens Meld for each conflicted file. You resolve the conflicts in the GUI, save the merged result, and then continue the Git operation. A typical sequence is:
For a rebase, the last step would usually be git rebase --continue.
A Useful .gitconfig Block
If you prefer editing config files directly, the equivalent block often looks like this:
That is functionally the same as the earlier git config --global commands.
Local Versus Global Configuration
If you only want Meld for one repository, omit --global and run the same configuration inside that repository. That stores the values in .git/config instead of your home directory, which is useful when different projects prefer different tools.
Why trustExitCode Matters
trustExitCode tells Git whether it should rely on the merge tool's process result to determine success. With Meld, setting it to true is common because it reduces extra prompts and keeps the workflow smoother. If your environment behaves strangely, you can turn it off and let Git ask whether the merge was completed.
Common Pitfalls
The most common problem is that Git says the tool is unknown or cannot be launched. That usually means the meld executable is not on PATH, or the configured command is wrong for the local platform.
Another issue is expecting git diff itself to open the GUI. It will not. The GUI integration happens through git difftool.
Merge users also sometimes forget that saving the file in Meld is only part of the process. Git still needs the resolved file staged with git add before the merge or rebase can finish.
Finally, be careful with blanket git add . after conflict resolution if unrelated files are present. It is often safer to stage only the files you actually resolved.
Summary
- Configure Meld as both Git
difftoolandmergetoolthrough global Git settings. - Use
git difftoolfor graphical change review andgit mergetoolfor conflict resolution. - If
meldis not onPATH, set explicitdifftool.meld.cmdandmergetool.meld.cmdvalues. - Save the resolved file in Meld, then stage it in Git.
- '
trustExitCodeusually makes the merge workflow smoother when Meld is configured correctly.'

