2 .\" Title: git-mergetool
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
7 .\" Source: Git 2.47.0.305.g4083a6f052
10 .TH "GIT\-MERGETOOL" "1" "2024-11-20" "Git 2\&.47\&.0\&.305\&.g4083a6" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-mergetool \- Run merge conflict resolution tools to resolve merge conflicts
35 \fIgit mergetool\fR [\-\-tool=<tool>] [\-y | \-\-[no\-]prompt] [<file>\&...\:]
39 Use \fBgit\fR \fBmergetool\fR to run one of several merge utilities to resolve merge conflicts\&. It is typically run after \fIgit merge\fR\&.
41 If one or more <file> parameters are given, the merge tool program will be run to resolve differences in each file (skipping those without conflicts)\&. Specifying a directory will include all unresolved files in that path\&. If no <file> names are specified, \fIgit mergetool\fR will run the merge tool program on every file with merge conflicts\&.
44 \-t <tool>, \-\-tool=<tool>
46 Use the merge resolution program specified by <tool>\&. Valid values include emerge, gvimdiff, kdiff3, meld, vimdiff, and tortoisemerge\&. Run
50 for the list of valid <tool> settings\&.
52 If a merge resolution program is not specified,
54 will use the configuration variable
55 \fBmerge\&.tool\fR\&. If the configuration variable
59 will pick a suitable default\&.
61 You can explicitly provide a full path to the tool by setting the configuration variable
62 \fBmergetool\&.\fR\fI<tool>\fR\fB\&.path\fR\&. For example, you can configure the absolute path to kdiff3 by setting
63 \fBmergetool\&.kdiff3\&.path\fR\&. Otherwise,
65 assumes the tool is available in PATH\&.
67 Instead of running one of the known merge tool programs,
69 can be customized to run an alternative program by specifying the command line to invoke in a configuration variable
70 \fBmergetool\&.\fR\fI<tool>\fR\fB\&.cmd\fR\&.
74 is invoked with this tool (either through the
80 configuration variable), the configured command line will be invoked with
82 set to the name of a temporary file containing the common base for the merge, if available;
84 set to the name of a temporary file containing the contents of the file on the current branch;
86 set to the name of a temporary file containing the contents of the file to be merged, and
88 set to the name of the file to which the merge tool should write the result of the merge resolution\&.
90 If the custom merge tool correctly indicates the success of a merge resolution with its exit code, then the configuration variable
91 \fBmergetool\&.\fR\fI<tool>\fR\fB\&.trustExitCode\fR
93 \fBtrue\fR\&. Otherwise,
95 will prompt the user to indicate the success of the resolution after the custom tool has exited\&.
100 Print a list of merge tools that may be used with
106 Don\(cqt prompt before each invocation of the merge resolution program\&. This is the default if the merge resolution program is explicitly specified with the
110 configuration variable\&.
115 Prompt before each invocation of the merge resolution program to give the user a chance to skip the path\&.
126 option, the default merge tool will be read from the configured
127 \fBmerge\&.guitool\fR
129 \fBmerge\&.tool\fR\&. If
130 \fBmerge\&.guitool\fR
131 is not set, we will fallback to the tool configured under
132 \fBmerge\&.tool\fR\&. This may be autoselected using the configuration variable
133 \fBmergetool\&.guiDefault\fR\&.
138 This overrides a previous
143 \fBmergetool\&.guiDefault\fR
144 configuration and reads the default merge tool from the configured
151 Process files in the order specified in the <orderfile>, which has one shell glob pattern per line\&. This overrides the
152 \fBdiff\&.orderFile\fR
153 configuration variable (see
154 \fBgit-config\fR(1))\&. To cancel
155 \fBdiff\&.orderFile\fR, use
156 \fB\-O/dev/null\fR\&.
160 Everything below this line in this section is selectively included from the \fBgit-config\fR(1) documentation\&. The content is the same as what\(cqs found there:
162 mergetool\&.<tool>\&.path
164 Override the path for the given tool\&. This is useful in case your tool is not in the PATH\&.
167 mergetool\&.<tool>\&.cmd
169 Specify the command to invoke the specified merge tool\&. The specified command is evaluated in shell with the following variables available:
171 is the name of a temporary file containing the common base of the files to be merged, if available;
173 is the name of a temporary file containing the contents of the file on the current branch;
175 is the name of a temporary file containing the contents of the file from the branch being merged;
177 contains the name of the file to which the merge tool should write the results of a successful merge\&.
180 mergetool\&.<tool>\&.hideResolved
182 Allows the user to override the global
183 \fBmergetool\&.hideResolved\fR
184 value for a specific tool\&. See
185 \fBmergetool\&.hideResolved\fR
186 for the full description\&.
189 mergetool\&.<tool>\&.trustExitCode
191 For a custom merge command, specify whether the exit code of the merge command can be used to determine whether the merge was successful\&. If this is not set to true then the merge target file timestamp is checked, and the merge is assumed to have been successful if the file has been updated; otherwise, the user is prompted to indicate the success of the merge\&.
194 mergetool\&.meld\&.hasOutput
200 option\&. Git will attempt to detect whether
204 by inspecting the output of
206 \fB\-\-help\fR\&. Configuring
207 \fBmergetool\&.meld\&.hasOutput\fR
208 will make Git skip these checks and use the configured value instead\&. Setting
209 \fBmergetool\&.meld\&.hasOutput\fR
212 tells Git to unconditionally use the
220 mergetool\&.meld\&.useAutoMerge
223 \fB\-\-auto\-merge\fR
224 is given, meld will merge all non\-conflicting parts automatically, highlight the conflicting parts, and wait for user decision\&. Setting
225 \fBmergetool\&.meld\&.useAutoMerge\fR
228 tells Git to unconditionally use the
229 \fB\-\-auto\-merge\fR
231 \fBmeld\fR\&. Setting this value to
233 makes git detect whether
234 \fB\-\-auto\-merge\fR
235 is supported and will only use
236 \fB\-\-auto\-merge\fR
237 when available\&. A value of
240 \fB\-\-auto\-merge\fR
241 altogether, and is the default value\&.
244 mergetool\&.<vimdiff variant>\&.layout
246 Configure the split window layout for vimdiff\(cqs
247 \fI<variant>\fR, which is any of
250 \fBgvimdiff\fR\&. Upon launching
254 \fB\-\-tool=\fR\fI<variant>\fR
260 \fI<variant>\fR), Git will consult
261 \fBmergetool\&.\fR\fI<variant>\fR\fB\&.layout\fR
262 to determine the tool\(cqs layout\&. If the variant\-specific configuration is not available,
263 \fBvimdiff\fR\*(Aqs is used as fallback\&. If that too is not available, a default layout with 4 windows will be used\&. To configure the layout, see the
270 mergetool\&.hideResolved
272 During a merge, Git will automatically resolve as many conflicts as possible and write the
274 file containing conflict markers around any conflicts that it cannot resolve;
278 normally represent the versions of the file from before Git\(cqs conflict resolution\&. This flag causes
282 to be overwritten so that only the unresolved conflicts are presented to the merge tool\&. Can be configured per\-tool via the
283 \fBmergetool\&.\fR\fI<tool>\fR\fB\&.hideResolved\fR
284 configuration variable\&. Defaults to
288 mergetool\&.keepBackup
290 After performing a merge, the original file with conflict markers can be saved as a file with a \&.\fBorig\fR
291 extension\&. If this variable is set to
293 then this file is not preserved\&. Defaults to
295 (i\&.e\&. keep the backup files)\&.
298 mergetool\&.keepTemporaries
300 When invoking a custom merge tool, Git uses a set of temporary files to pass to the tool\&. If the tool returns an error and this variable is set to
301 \fBtrue\fR, then these temporary files will be preserved; otherwise, they will be removed after the tool has exited\&. Defaults to
305 mergetool\&.writeToTemp
311 versions of conflicting files in the worktree by default\&. Git will attempt to use a temporary directory for these files when set
312 \fBtrue\fR\&. Defaults to
318 Prompt before each invocation of the merge resolution program\&.
321 mergetool\&.guiDefault
326 \fBmerge\&.guitool\fR
327 by default (equivalent to specifying the
332 \fBmerge\&.guitool\fR
335 depending on the presence of a
337 environment variable value\&. The default is
338 \fBfalse\fR, where the
340 argument must be provided explicitly for the
341 \fBmerge\&.guitool\fR
344 .SH "TEMPORARY FILES"
346 \fBgit\fR \fBmergetool\fR creates *\&.\fBorig\fR backup files while resolving merges\&. These are safe to remove once a file has been merged and its \fBgit\fR \fBmergetool\fR session has completed\&.
348 Setting the \fBmergetool\&.keepBackup\fR configuration variable to \fBfalse\fR causes \fBgit\fR \fBmergetool\fR to automatically remove the backup files as files are successfully merged\&.
349 .SH "BACKEND SPECIFIC HINTS"
353 .nr an-no-space-flag 1
360 When specifying \fB\-\-tool=vimdiff\fR in \fBgit\fR \fBmergetool\fR Git will open Vim with a 4 windows layout distributed in the following way:
366 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
368 | LOCAL | BASE | REMOTE |
370 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
374 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
380 \fBLOCAL\fR, \fBBASE\fR and \fBREMOTE\fR are read\-only buffers showing the contents of the conflicting file in specific commits ("commit you are merging into", "common ancestor commit" and "commit you are merging from" respectively)
382 \fBMERGED\fR is a writable buffer where you have to resolve the conflicts (using the other read\-only buffers as a reference)\&. Once you are done, save and exit Vim as usual (\fB:wq\fR) or, if you want to abort, exit using \fB:cq\fR\&.
386 .nr an-no-space-flag 1
390 \fBLayout configuration\fR
393 You can change the windows layout used by Vim by setting configuration variable \fBmergetool\&.vimdiff\&.layout\fR which accepts a string where the following separators have special meaning:
404 is used to "open a new tab"
416 is used to "open a new vertical split"
428 is used to "open a new horizontal split"
440 is used to indicate the file containing the final version after solving the conflicts\&. If not present,
442 will be used by default\&.
445 The precedence of the operators is as follows (you can use parentheses to change it):
451 `@` > `+` > `/` > `,`
457 Let\(cqs see some examples to understand how it works:
469 "(\fBLOCAL,BASE,REMOTE\fR)\fB/MERGED\fR"
471 This is exactly the same as the default layout we have already seen\&.
477 and thus the parenthesis are not needed in this case\&. The next layout definition is equivalent:
483 layout = "LOCAL,BASE,REMOTE / MERGED"
500 "LOCAL,MERGED,REMOTE"
502 If, for some reason, we are not interested in the
510 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
513 | LOCAL | MERGED | REMOTE |
516 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
537 buffer will be shown\&. Note, however, that all the other ones are still loaded in vim, and you can access them with the "buffers" command\&.
543 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
549 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
570 is not present in the layout, you must "mark" one of the buffers with an asterisk\&. That will become the buffer you need to edit and save after resolving the conflicts\&.
576 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
584 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
609 Three tabs will open: the first one is a copy of the default layout, while the other two only show the differences between (\fBBASE\fR
611 \fBLOCAL\fR) and (\fBBASE\fR
613 \fBREMOTE\fR) respectively\&.
619 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
620 | <TAB #1> | TAB #2 | TAB #3 | |
621 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
623 | LOCAL | BASE | REMOTE |
625 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
629 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
639 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
640 | TAB #1 | <TAB #2> | TAB #3 | |
641 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
649 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
659 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
660 | TAB #1 | TAB #2 | <TAB #3> | |
661 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
669 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
694 (\fBLOCAL/BASE/REMOTE\fR)\fB,MERGED\fR"
696 Same as the previous example, but adds a fourth tab with the same information as the first tab, with a different layout\&.
702 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
703 | TAB #1 | TAB #2 | TAB #3 | <TAB #4> |
704 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
706 |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-| |
708 |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-| |
710 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
716 Note how in the third tab definition we need to use parentheses to make
724 .nr an-no-space-flag 1
731 Instead of \fB\-\-tool=vimdiff\fR, you can also use one of these other variants:
741 \fB\-\-tool=gvimdiff\fR, to open gVim instead of Vim\&.
752 \fB\-\-tool=nvimdiff\fR, to open Neovim instead of Vim\&.
755 When using these variants, in order to specify a custom layout you will have to set configuration variables \fBmergetool\&.gvimdiff\&.layout\fR and \fBmergetool\&.nvimdiff\&.layout\fR instead of \fBmergetool\&.vimdiff\&.layout\fR (though the latter will be used as fallback if the variant\-specific one is not set)\&.
757 In addition, for backwards compatibility with previous Git versions, you can also append \fB1\fR, \fB2\fR or \fB3\fR to either \fBvimdiff\fR or any of the variants (ex: \fBvimdiff3\fR, \fBnvimdiff1\fR, etc\&...\:) to use a predefined layout\&. In other words, using \fB\-\-tool=\fR[\fBg,n,\fR]\fBvimdiffx\fR is the same as using \fB\-\-tool=\fR[\fBg,n,\fR]\fBvimdiff\fR and setting configuration variable \fBmergetool\&.\fR[\fBg,n,\fR]\fBvimdiff\&.layout\fR to\&...\:
795 Example: using \fB\-\-tool=gvimdiff2\fR will open \fBgvim\fR with three columns (LOCAL, MERGED and REMOTE)\&.
799 Part of the \fBgit\fR(1) suite