{
    "mode": "man",
    "parameter": "git-mergetool",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-mergetool/1/json",
    "generated": "2026-10-25T20:27:58Z",
    "synopsis": "git mergetool [--tool=<tool>] [-y | --[no-]prompt] [<file>...]",
    "sections": {
        "NAME": {
            "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git mergetool [--tool=<tool>] [-y | --[no-]prompt] [<file>...]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Use git mergetool to run one of several merge utilities to resolve merge conflicts. It is\ntypically run after git merge.\n\nIf one or more <file> parameters are given, the merge tool program will be run to resolve\ndifferences in each file (skipping those without conflicts). Specifying a directory will\ninclude all unresolved files in that path. If no <file> names are specified, git mergetool\nwill run the merge tool program on every file with merge conflicts.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "-t <tool>, --tool=<tool>\nUse the merge resolution program specified by <tool>. Valid values include emerge,\ngvimdiff, kdiff3, meld, vimdiff, and tortoisemerge. Run git mergetool --tool-help for the\nlist of valid <tool> settings.\n\nIf a merge resolution program is not specified, git mergetool will use the configuration\nvariable merge.tool. If the configuration variable merge.tool is not set, git mergetool\nwill pick a suitable default.\n\nYou can explicitly provide a full path to the tool by setting the configuration variable\nmergetool.<tool>.path. For example, you can configure the absolute path to kdiff3 by\nsetting mergetool.kdiff3.path. Otherwise, git mergetool assumes the tool is available in\nPATH.\n\nInstead of running one of the known merge tool programs, git mergetool can be customized\nto run an alternative program by specifying the command line to invoke in a configuration\nvariable mergetool.<tool>.cmd.\n\nWhen git mergetool is invoked with this tool (either through the -t or --tool option or\nthe merge.tool configuration variable), the configured command line will be invoked with\n$BASE set to the name of a temporary file containing the common base for the merge, if\navailable; $LOCAL set to the name of a temporary file containing the contents of the file\non the current branch; $REMOTE set to the name of a temporary file containing the\ncontents of the file to be merged, and $MERGED set to the name of the file to which the\nmerge tool should write the result of the merge resolution.\n\nIf the custom merge tool correctly indicates the success of a merge resolution with its\nexit code, then the configuration variable mergetool.<tool>.trustExitCode can be set to\ntrue. Otherwise, git mergetool will prompt the user to indicate the success of the\nresolution after the custom tool has exited.\n",
            "subsections": [
                {
                    "name": "--tool-help",
                    "content": "Print a list of merge tools that may be used with --tool.\n",
                    "long": "--tool-help"
                },
                {
                    "name": "-y, --no-prompt",
                    "content": "Don’t prompt before each invocation of the merge resolution program. This is the default\nif the merge resolution program is explicitly specified with the --tool option or with\nthe merge.tool configuration variable.\n",
                    "flag": "-y",
                    "long": "--no-prompt"
                },
                {
                    "name": "--prompt",
                    "content": "Prompt before each invocation of the merge resolution program to give the user a chance\nto skip the path.\n",
                    "long": "--prompt"
                },
                {
                    "name": "-g, --gui",
                    "content": "When git-mergetool is invoked with the -g or --gui option, the default merge tool will be\nread from the configured merge.guitool variable instead of merge.tool. If merge.guitool\nis not set, we will fallback to the tool configured under merge.tool. This may be\nautoselected using the configuration variable mergetool.guiDefault.\n",
                    "flag": "-g",
                    "long": "--gui"
                },
                {
                    "name": "--no-gui",
                    "content": "This overrides a previous -g or --gui setting or mergetool.guiDefault configuration and\nreads the default merge tool from the configured merge.tool variable.\n",
                    "long": "--no-gui"
                },
                {
                    "name": "-O<orderfile>",
                    "content": "Process files in the order specified in the <orderfile>, which has one shell glob pattern\nper line. This overrides the diff.orderFile configuration variable (see git-config(1)).\nTo cancel diff.orderFile, use -O/dev/null.\n"
                }
            ]
        },
        "CONFIGURATION": {
            "content": "Everything below this line in this section is selectively included from the git-config(1)\ndocumentation. The content is the same as what’s found there:\n\nmergetool.<tool>.path\nOverride the path for the given tool. This is useful in case your tool is not in the\nPATH.\n\nmergetool.<tool>.cmd\nSpecify the command to invoke the specified merge tool. The specified command is\nevaluated in shell with the following variables available: BASE is the name of a\ntemporary file containing the common base of the files to be merged, if available; LOCAL\nis the name of a temporary file containing the contents of the file on the current\nbranch; REMOTE is the name of a temporary file containing the contents of the file from\nthe branch being merged; MERGED contains the name of the file to which the merge tool\nshould write the results of a successful merge.\n\nmergetool.<tool>.hideResolved\nAllows the user to override the global mergetool.hideResolved value for a specific tool.\nSee mergetool.hideResolved for the full description.\n\nmergetool.<tool>.trustExitCode\nFor a custom merge command, specify whether the exit code of the merge command can be\nused to determine whether the merge was successful. If this is not set to true then the\nmerge target file timestamp is checked, and the merge is assumed to have been successful\nif the file has been updated; otherwise, the user is prompted to indicate the success of\nthe merge.\n\nmergetool.meld.hasOutput\nOlder versions of meld do not support the --output option. Git will attempt to detect\nwhether meld supports --output by inspecting the output of meld --help. Configuring\nmergetool.meld.hasOutput will make Git skip these checks and use the configured value\ninstead. Setting mergetool.meld.hasOutput to true tells Git to unconditionally use the\n--output option, and false avoids using --output.\n\nmergetool.meld.useAutoMerge\nWhen the --auto-merge is given, meld will merge all non-conflicting parts automatically,\nhighlight the conflicting parts, and wait for user decision. Setting\nmergetool.meld.useAutoMerge to true tells Git to unconditionally use the --auto-merge\noption with meld. Setting this value to auto makes git detect whether --auto-merge is\nsupported and will only use --auto-merge when available. A value of false avoids using\n--auto-merge altogether, and is the default value.\n\nmergetool.vimdiff.layout\nThe vimdiff backend uses this variable to control how its split windows appear. Applies\neven if you are using Neovim (nvim) or gVim (gvim) as the merge tool. See BACKEND\nSPECIFIC HINTS section for details.\n\nmergetool.hideResolved\nDuring a merge, Git will automatically resolve as many conflicts as possible and write\nthe MERGED file containing conflict markers around any conflicts that it cannot resolve;\nLOCAL and REMOTE normally represent the versions of the file from before Git’s conflict\nresolution. This flag causes LOCAL and REMOTE to be overwritten so that only the\nunresolved conflicts are presented to the merge tool. Can be configured per-tool via the\nmergetool.<tool>.hideResolved configuration variable. Defaults to false.\n\nmergetool.keepBackup\nAfter performing a merge, the original file with conflict markers can be saved as a file\nwith a .orig extension. If this variable is set to false then this file is not preserved.\nDefaults to true (i.e. keep the backup files).\n\nmergetool.keepTemporaries\nWhen invoking a custom merge tool, Git uses a set of temporary files to pass to the tool.\nIf the tool returns an error and this variable is set to true, then these temporary files\nwill be preserved; otherwise, they will be removed after the tool has exited. Defaults to\nfalse.\n\nmergetool.writeToTemp\nGit writes temporary BASE, LOCAL, and REMOTE versions of conflicting files in the\nworktree by default. Git will attempt to use a temporary directory for these files when\nset true. Defaults to false.\n\nmergetool.prompt\nPrompt before each invocation of the merge resolution program.\n\nmergetool.guiDefault\nSet true to use the merge.guitool by default (equivalent to specifying the --gui\nargument), or auto to select merge.guitool or merge.tool depending on the presence of a\nDISPLAY environment variable value. The default is false, where the --gui argument must\nbe provided explicitly for the merge.guitool to be used.\n",
            "subsections": []
        },
        "TEMPORARY FILES": {
            "content": "git mergetool creates *.orig backup files while resolving merges. These are safe to remove\nonce a file has been merged and its git mergetool session has completed.\n\nSetting the mergetool.keepBackup configuration variable to false causes git mergetool to\nautomatically remove the backup files as files are successfully merged.\n",
            "subsections": []
        },
        "BACKEND SPECIFIC HINTS": {
            "content": "",
            "subsections": [
                {
                    "name": "vimdiff",
                    "content": ""
                },
                {
                    "name": "Description",
                    "content": "When specifying --tool=vimdiff in git mergetool Git will open Vim with a 4 windows layout\ndistributed in the following way:\n\n------------------------------------------\n|             |           |              |\n|   LOCAL     |   BASE    |   REMOTE     |\n|             |           |              |\n------------------------------------------\n|                                        |\n|                MERGED                  |\n|                                        |\n------------------------------------------\n\nLOCAL, BASE and REMOTE are read-only buffers showing the contents of the conflicting file\nin specific commits (\"commit you are merging into\", \"common ancestor commit\" and \"commit\nyou are merging from\" respectively)\n\nMERGED is a writable buffer where you have to resolve the conflicts (using the other\nread-only buffers as a reference). Once you are done, save and exit Vim as usual (:wq)\nor, if you want to abort, exit using :cq.\n"
                },
                {
                    "name": "Layout configuration",
                    "content": "You can change the windows layout used by Vim by setting configuration variable\nmergetool.vimdiff.layout which accepts a string where the following separators have\nspecial meaning:\n\n•   + is used to \"open a new tab\"\n\n•   , is used to \"open a new vertical split\"\n\n•   / is used to \"open a new horizontal split\"\n\n•   @ is used to indicate the file containing the final version after solving the\nconflicts. If not present, MERGED will be used by default.\n\nThe precedence of the operators is as follows (you can use parentheses to change it):\n\n`@` > `+` > `/` > `,`\n\nLet’s see some examples to understand how it works:\n\n•   layout = \"(LOCAL,BASE,REMOTE)/MERGED\"\n\nThis is exactly the same as the default layout we have already seen.\n\nNote that / has precedence over , and thus the parenthesis are not needed in this\ncase. The next layout definition is equivalent:\n\nlayout = \"LOCAL,BASE,REMOTE / MERGED\"\n\n•   layout = \"LOCAL,MERGED,REMOTE\"\n\nIf, for some reason, we are not interested in the BASE buffer.\n\n------------------------------------------\n|             |           |              |\n|             |           |              |\n|   LOCAL     |   MERGED  |   REMOTE     |\n|             |           |              |\n|             |           |              |\n------------------------------------------\n\n•   layout = \"MERGED\"\n\nOnly the MERGED buffer will be shown. Note, however, that all the other ones are\nstill loaded in vim, and you can access them with the \"buffers\" command.\n\n------------------------------------------\n|                                        |\n|                                        |\n|                 MERGED                 |\n|                                        |\n|                                        |\n------------------------------------------\n\n•   layout = \"@LOCAL,REMOTE\"\n\nWhen MERGED is not present in the layout, you must \"mark\" one of the buffers with an\nasterisk. That will become the buffer you need to edit and save after resolving the\nconflicts.\n\n------------------------------------------\n|                   |                    |\n|                   |                    |\n|                   |                    |\n|     LOCAL         |    REMOTE          |\n|                   |                    |\n|                   |                    |\n|                   |                    |\n------------------------------------------\n\n•   layout = \"LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE\"\n\nThree tabs will open: the first one is a copy of the default layout, while the other\ntwo only show the differences between (BASE and LOCAL) and (BASE and REMOTE)\nrespectively.\n\n------------------------------------------\n| <TAB #1> |  TAB #2  |  TAB #3  |       |\n------------------------------------------\n|             |           |              |\n|   LOCAL     |   BASE    |   REMOTE     |\n|             |           |              |\n------------------------------------------\n|                                        |\n|                MERGED                  |\n|                                        |\n------------------------------------------\n\n------------------------------------------\n|  TAB #1  | <TAB #2> |  TAB #3  |       |\n------------------------------------------\n|                   |                    |\n|                   |                    |\n|                   |                    |\n|     BASE          |    LOCAL           |\n|                   |                    |\n|                   |                    |\n|                   |                    |\n------------------------------------------\n\n------------------------------------------\n|  TAB #1  |  TAB #2  | <TAB #3> |       |\n------------------------------------------\n|                   |                    |\n|                   |                    |\n|                   |                    |\n|     BASE          |    REMOTE          |\n|                   |                    |\n|                   |                    |\n|                   |                    |\n------------------------------------------\n\n•   layout = \"LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE +\n(LOCAL/BASE/REMOTE),MERGED\"\n\nSame as the previous example, but adds a fourth tab with the same information as the\nfirst tab, with a different layout.\n\n---------------------------------------------\n|  TAB #1  |  TAB #2  |  TAB #3  | <TAB #4> |\n---------------------------------------------\n|       LOCAL         |                     |\n|---------------------|                     |\n|       BASE          |        MERGED       |\n|---------------------|                     |\n|       REMOTE        |                     |\n---------------------------------------------\n\nNote how in the third tab definition we need to use parentheses to make , have\nprecedence over /.\n"
                },
                {
                    "name": "Variants",
                    "content": "Instead of --tool=vimdiff, you can also use one of these other variants:\n\n•   --tool=gvimdiff, to open gVim instead of Vim.\n\n•   --tool=nvimdiff, to open Neovim instead of Vim.\n\nWhen using these variants, in order to specify a custom layout you will have to set\nconfiguration variables mergetool.gvimdiff.layout and mergetool.nvimdiff.layout instead\nof mergetool.vimdiff.layout\n\nIn addition, for backwards compatibility with previous Git versions, you can also append\n1, 2 or 3 to either vimdiff or any of the variants (ex: vimdiff3, nvimdiff1, etc...) to\nuse a predefined layout. In other words, using --tool=[g,n,]vimdiffx is the same as using\n--tool=[g,n,]vimdiff and setting configuration variable mergetool.[g,n,]vimdiff.layout\nto...\n\n•   x=1: \"@LOCAL, REMOTE\"\n\n•   x=2: \"LOCAL, MERGED, REMOTE\"\n\n•   x=3: \"MERGED\"\n\nExample: using --tool=gvimdiff2 will open gvim with three columns (LOCAL, MERGED and\nREMOTE).\n"
                }
            ]
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\nGit 2.43.0                                   07/02/2025                             GIT-MERGETOOL(1)",
            "subsections": []
        }
    },
    "summary": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts",
    "flags": [
        {
            "flag": "",
            "long": "--tool-help",
            "arg": null,
            "description": "Print a list of merge tools that may be used with --tool."
        },
        {
            "flag": "-y",
            "long": "--no-prompt",
            "arg": null,
            "description": "Don’t prompt before each invocation of the merge resolution program. This is the default if the merge resolution program is explicitly specified with the --tool option or with the merge.tool configuration variable."
        },
        {
            "flag": "",
            "long": "--prompt",
            "arg": null,
            "description": "Prompt before each invocation of the merge resolution program to give the user a chance to skip the path."
        },
        {
            "flag": "-g",
            "long": "--gui",
            "arg": null,
            "description": "When git-mergetool is invoked with the -g or --gui option, the default merge tool will be read from the configured merge.guitool variable instead of merge.tool. If merge.guitool is not set, we will fallback to the tool configured under merge.tool. This may be autoselected using the configuration variable mergetool.guiDefault."
        },
        {
            "flag": "",
            "long": "--no-gui",
            "arg": null,
            "description": "This overrides a previous -g or --gui setting or mergetool.guiDefault configuration and reads the default merge tool from the configured merge.tool variable."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Process files in the order specified in the <orderfile>, which has one shell glob pattern per line. This overrides the diff.orderFile configuration variable (see git-config(1)). To cancel diff.orderFile, use -O/dev/null."
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Run merge conflict resolution tools to resolve merge conflicts.",
        "examples": [
            {
                "description": "Launch the default merge tool to resolve conflicts",
                "command": "git mergetool"
            },
            {
                "description": "List valid merge tools",
                "command": "git mergetool --tool-help"
            },
            {
                "description": "Launch the merge tool identified by a name",
                "command": "git mergetool {{-t|--tool}} {{tool_name}}"
            },
            {
                "description": "Don't prompt before each invocation of the merge tool",
                "command": "git mergetool {{-y|--no-prompt}}"
            },
            {
                "description": "Explicitly use the GUI merge tool (see the `merge.guitool` configuration variable)",
                "command": "git mergetool {{-g|--gui}}"
            },
            {
                "description": "Explicitly use the regular merge tool (see the `merge.tool` configuration variable)",
                "command": "git mergetool --no-gui"
            }
        ]
    }
}