> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diversion.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# merge-tool

> List, add, or remove the external merge tools that resolve merge conflicts.

The `merge-tool` command manages your **external merge tools**. Diversion runs them when you merge, update, or revert with `--conflict_resolution merge-tool`. For how the flow works and ready-to-use examples, see the [External Merge Tools guide](/advanced/external-merge-tools).

Your tools are saved for your user on this computer, not in the repository. If more than one tool matches a file, the **first tool in the list wins**.

## list

Show your tools, in the order Diversion matches them.

```bash theme={null}
dv merge-tool
```

`dv merge-tool -l` does the same thing. For each tool, it prints the name, the pattern, whether the exit code is trusted, and the command. With no tools, it prints `No merge tools configured`.

## add

Add a tool.

```bash theme={null}
dv merge-tool add --name <name> --pattern <regex> --cmd <command> [--no-trust-exit-code]
```

`--name` is a unique name for the tool. If a tool with this name already exists, Diversion replaces it and keeps its place in the list. A new tool goes to the end of the list.

`--pattern` is a regular expression matched against the file path, for example `\.prefab$`. See [file patterns](/advanced/external-merge-tools#file-patterns).

`--cmd` is the command line to run. It must include `$RESULT`, the file where the tool writes the result. You can also use `$ANCESTOR`, `$CURRENT`, and `$INCOMING`. See [command placeholders](/advanced/external-merge-tools#command-placeholders).

`[--no-trust-exit-code]` ignores the exit code of the tool and checks the merged file instead. Use it for visual tools that exit with `0` even when you close them without saving.

On Mac and Linux, put `--pattern` and `--cmd` in single quotes so your shell does not change `$` and other special characters.

Example:

```bash theme={null}
dv merge-tool add --name mergiraf --pattern '\.(json|ya?ml)$' --cmd 'mergiraf merge $ANCESTOR $CURRENT $INCOMING -o $RESULT'
```

## -d

Remove a tool by name.

```bash theme={null}
dv merge-tool -d <name>
```

Example:

```bash theme={null}
dv merge-tool -d mergiraf
```

## Use your tools

```bash theme={null}
dv merge <branch> --conflict_resolution merge-tool
dv update --conflict_resolution merge-tool
dv revert <commit_id> --conflict_resolution merge-tool
```

See [Resolve conflicts with your merge tools](/advanced/external-merge-tools#resolve-conflicts-with-your-merge-tools).
