{
    "mode": "info",
    "parameter": "git-mergetool",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/git-mergetool/json",
    "generated": "2026-07-11T01:13:37Z",
    "synopsis": "git mergetool [--tool=<tool>] [-y | --[no-]prompt] [<file>...]",
    "sections": {
        "NAME": {
            "content": "git-mergetool - Run merge conflict resolution tools to resolve merge\nconflicts\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git mergetool [--tool=<tool>] [-y | --[no-]prompt] [<file>...]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Use git mergetool to run one of several merge utilities to resolve\nmerge conflicts. It is typically run after git merge.\n\nIf one or more <file> parameters are given, the merge tool program will\nbe run to resolve differences on each file (skipping those without\nconflicts). Specifying a directory will include all unresolved files in\nthat path. If no <file> names are specified, git mergetool will run the\nmerge 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\ninclude emerge, gvimdiff, kdiff3, meld, vimdiff, and tortoisemerge.\nRun git mergetool --tool-help for the list of valid <tool>\nsettings.\n\nIf a merge resolution program is not specified, git mergetool will\nuse the configuration variable merge.tool. If the configuration\nvariable merge.tool is not set, git mergetool will pick a suitable\ndefault.\n\nYou can explicitly provide a full path to the tool by setting the\nconfiguration variable mergetool.<tool>.path. For example, you can\nconfigure the absolute path to kdiff3 by setting\nmergetool.kdiff3.path. Otherwise, git mergetool assumes the tool is\navailable in PATH.\n\nInstead of running one of the known merge tool programs, git\nmergetool can be customized to run an alternative program by\nspecifying the command line to invoke in a configuration variable\nmergetool.<tool>.cmd.\n\nWhen git mergetool is invoked with this tool (either through the -t\nor --tool option or the merge.tool configuration variable) the\nconfigured command line will be invoked with $BASE set to the name\nof a temporary file containing the common base for the merge, if\navailable; $LOCAL set to the name of a temporary file containing\nthe contents of the file on the current branch; $REMOTE set to the\nname of a temporary file containing the contents of the file to be\nmerged, and $MERGED set to the name of the file to which the merge\ntool should write the result of the merge resolution.\n\nIf the custom merge tool correctly indicates the success of a merge\nresolution with its exit code, then the configuration variable\nmergetool.<tool>.trustExitCode can be set to true. Otherwise, git\nmergetool 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\nprogram. This is the default if the merge resolution program is\nexplicitly specified with the --tool option or with the merge.tool\nconfiguration variable.\n",
                    "flag": "-y",
                    "long": "--no-prompt"
                },
                {
                    "name": "--prompt",
                    "content": "Prompt before each invocation of the merge resolution program to\ngive the user a chance to skip the path.\n",
                    "long": "--prompt"
                },
                {
                    "name": "-g, --gui",
                    "content": "When git-mergetool is invoked with the -g or --gui option the\ndefault merge tool will be read from the configured merge.guitool\nvariable instead of merge.tool. If merge.guitool is not set, we\nwill fallback to the tool configured under merge.tool.\n",
                    "flag": "-g",
                    "long": "--gui"
                },
                {
                    "name": "--no-gui",
                    "content": "This overrides a previous -g or --gui setting and reads the default\nmerge tool will be read 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\none shell glob pattern per line. This overrides the diff.orderFile\nconfiguration variable (see git-config(1)). To cancel\ndiff.orderFile, use -O/dev/null.\n"
                }
            ]
        },
        "CONFIGURATION": {
            "content": "mergetool.<tool>.path\nOverride the path for the given tool. This is useful in case your\ntool is not in the PATH.\n\nmergetool.<tool>.cmd\nSpecify the command to invoke the specified merge tool. The\nspecified command is evaluated in shell with the following\nvariables available: BASE is the name of a temporary file\ncontaining the common base of the files to be merged, if available;\nLOCAL is the name of a temporary file containing the contents of\nthe file on the current branch; REMOTE is the name of a temporary\nfile containing the contents of the file from the branch being\nmerged; MERGED contains the name of the file to which the merge\ntool should write the results of a successful merge.\n\nmergetool.<tool>.hideResolved\nAllows the user to override the global mergetool.hideResolved value\nfor a specific tool. See mergetool.hideResolved for the full\ndescription.\n\nmergetool.<tool>.trustExitCode\nFor a custom merge command, specify whether the exit code of the\nmerge command can be used to determine whether the merge was\nsuccessful. If this is not set to true then the merge target file\ntimestamp is checked and the merge assumed to have been successful\nif the file has been updated, otherwise the user is prompted to\nindicate the success of the merge.\n\nmergetool.meld.hasOutput\nOlder versions of meld do not support the --output option. Git will\nattempt to detect whether meld supports --output by inspecting the\noutput of meld --help. Configuring mergetool.meld.hasOutput will\nmake Git skip these checks and use the configured value instead.\nSetting mergetool.meld.hasOutput to true tells Git to\nunconditionally use the --output option, and false avoids using\n--output.\n\nmergetool.meld.useAutoMerge\nWhen the --auto-merge is given, meld will merge all non-conflicting\nparts automatically, highlight the conflicting parts and wait for\nuser decision. Setting mergetool.meld.useAutoMerge to true tells\nGit to unconditionally use the --auto-merge option with meld.\nSetting this value to auto makes git detect whether --auto-merge is\nsupported and will only use --auto-merge when available. A value of\nfalse avoids using --auto-merge altogether, and is the default\nvalue.\n\nmergetool.hideResolved\nDuring a merge Git will automatically resolve as many conflicts as\npossible and write the MERGED file containing conflict markers\naround any conflicts that it cannot resolve; LOCAL and REMOTE\nnormally represent the versions of the file from before Git's\nconflict resolution. This flag causes LOCAL and REMOTE to be\noverwriten so that only the unresolved conflicts are presented to\nthe merge tool. Can be configured per-tool via the\nmergetool.<tool>.hideResolved configuration variable. Defaults to\nfalse.\n\nmergetool.keepBackup\nAfter performing a merge, the original file with conflict markers\ncan be saved as a file with a .orig extension. If this variable is\nset to false then this file is not preserved. Defaults to true\n(i.e. keep the backup files).\n\nmergetool.keepTemporaries\nWhen invoking a custom merge tool, Git uses a set of temporary\nfiles to pass to the tool. If the tool returns an error and this\nvariable is set to true, then these temporary files will be\npreserved, otherwise they will be removed after the tool has\nexited. Defaults to false.\n\nmergetool.writeToTemp\nGit writes temporary BASE, LOCAL, and REMOTE versions of\nconflicting files in the worktree by default. Git will attempt to\nuse a temporary directory for these files when set true. Defaults\nto false.\n\nmergetool.prompt\nPrompt before each invocation of the merge resolution program.\n",
            "subsections": []
        },
        "TEMPORARY FILES": {
            "content": "git mergetool creates *.orig backup files while resolving merges. These\nare safe to remove once a file has been merged and its git mergetool\nsession has completed.\n\nSetting the mergetool.keepBackup configuration variable to false causes\ngit mergetool to automatically remove the backup as files are\nsuccessfully merged.\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\nGit 2.34.1                        02/26/2026                  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."
        },
        {
            "flag": "",
            "long": "--no-gui",
            "arg": null,
            "description": "This overrides a previous -g or --gui setting and reads the default merge tool will be read 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": []
}