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.46.1.603.g94b60adee3
10 .TH "GIT\-MERGETOOL" "1" "2024-09-20" "Git 2\&.46\&.1\&.603\&.g94b60a" "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 mergetool\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
47 \fBgit mergetool \-\-tool\-help\fR
48 for the list of valid <tool> settings\&.
50 If a merge resolution program is not specified,
52 will use the configuration variable
53 \fBmerge\&.tool\fR\&. If the configuration variable
57 will pick a suitable default\&.
59 You can explicitly provide a full path to the tool by setting the configuration variable
60 \fBmergetool\&.<tool>\&.path\fR\&. For example, you can configure the absolute path to kdiff3 by setting
61 \fBmergetool\&.kdiff3\&.path\fR\&. Otherwise,
63 assumes the tool is available in PATH\&.
65 Instead of running one of the known merge tool programs,
67 can be customized to run an alternative program by specifying the command line to invoke in a configuration variable
68 \fBmergetool\&.<tool>\&.cmd\fR\&.
72 is invoked with this tool (either through the
78 configuration variable), the configured command line will be invoked with
80 set to the name of a temporary file containing the common base for the merge, if available;
82 set to the name of a temporary file containing the contents of the file on the current branch;
84 set to the name of a temporary file containing the contents of the file to be merged, and
86 set to the name of the file to which the merge tool should write the result of the merge resolution\&.
88 If the custom merge tool correctly indicates the success of a merge resolution with its exit code, then the configuration variable
89 \fBmergetool\&.<tool>\&.trustExitCode\fR
91 \fBtrue\fR\&. Otherwise,
93 will prompt the user to indicate the success of the resolution after the custom tool has exited\&.
98 Print a list of merge tools that may be used with
104 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
108 configuration variable\&.
113 Prompt before each invocation of the merge resolution program to give the user a chance to skip the path\&.
124 option, the default merge tool will be read from the configured
125 \fBmerge\&.guitool\fR
127 \fBmerge\&.tool\fR\&. If
128 \fBmerge\&.guitool\fR
129 is not set, we will fallback to the tool configured under
130 \fBmerge\&.tool\fR\&. This may be autoselected using the configuration variable
131 \fBmergetool\&.guiDefault\fR\&.
136 This overrides a previous
141 \fBmergetool\&.guiDefault\fR
142 configuration and reads the default merge tool from the configured
149 Process files in the order specified in the <orderfile>, which has one shell glob pattern per line\&. This overrides the
150 \fBdiff\&.orderFile\fR
151 configuration variable (see
152 \fBgit-config\fR(1))\&. To cancel
153 \fBdiff\&.orderFile\fR, use
154 \fB\-O/dev/null\fR\&.
158 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:
160 mergetool\&.<tool>\&.path
162 Override the path for the given tool\&. This is useful in case your tool is not in the PATH\&.
165 mergetool\&.<tool>\&.cmd
167 Specify the command to invoke the specified merge tool\&. The specified command is evaluated in shell with the following variables available:
169 is the name of a temporary file containing the common base of the files to be merged, if available;
171 is the name of a temporary file containing the contents of the file on the current branch;
173 is the name of a temporary file containing the contents of the file from the branch being merged;
175 contains the name of the file to which the merge tool should write the results of a successful merge\&.
178 mergetool\&.<tool>\&.hideResolved
180 Allows the user to override the global
181 \fBmergetool\&.hideResolved\fR
182 value for a specific tool\&. See
183 \fBmergetool\&.hideResolved\fR
184 for the full description\&.
187 mergetool\&.<tool>\&.trustExitCode
189 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\&.
192 mergetool\&.meld\&.hasOutput
198 option\&. Git will attempt to detect whether
202 by inspecting the output of
203 \fBmeld \-\-help\fR\&. Configuring
204 \fBmergetool\&.meld\&.hasOutput\fR
205 will make Git skip these checks and use the configured value instead\&. Setting
206 \fBmergetool\&.meld\&.hasOutput\fR
209 tells Git to unconditionally use the
217 mergetool\&.meld\&.useAutoMerge
220 \fB\-\-auto\-merge\fR
221 is given, meld will merge all non\-conflicting parts automatically, highlight the conflicting parts, and wait for user decision\&. Setting
222 \fBmergetool\&.meld\&.useAutoMerge\fR
225 tells Git to unconditionally use the
226 \fB\-\-auto\-merge\fR
228 \fBmeld\fR\&. Setting this value to
230 makes git detect whether
231 \fB\-\-auto\-merge\fR
232 is supported and will only use
233 \fB\-\-auto\-merge\fR
234 when available\&. A value of
237 \fB\-\-auto\-merge\fR
238 altogether, and is the default value\&.
241 mergetool\&.<vimdiff variant>\&.layout
243 Configure the split window layout for vimdiff\(cqs
244 \fB<variant>\fR, which is any of
247 \fBgvimdiff\fR\&. Upon launching
250 \fB\-\-tool=<variant>\fR
256 \fB<variant>\fR), Git will consult
257 \fBmergetool\&.<variant>\&.layout\fR
258 to determine the tool\(cqs layout\&. If the variant\-specific configuration is not available,
259 \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
260 \fBBACKEND SPECIFIC HINTS\fR
264 mergetool\&.hideResolved
266 During a merge, Git will automatically resolve as many conflicts as possible and write the
268 file containing conflict markers around any conflicts that it cannot resolve;
272 normally represent the versions of the file from before Git\(cqs conflict resolution\&. This flag causes
276 to be overwritten so that only the unresolved conflicts are presented to the merge tool\&. Can be configured per\-tool via the
277 \fBmergetool\&.<tool>\&.hideResolved\fR
278 configuration variable\&. Defaults to
282 mergetool\&.keepBackup
284 After performing a merge, the original file with conflict markers can be saved as a file with a
286 extension\&. If this variable is set to
288 then this file is not preserved\&. Defaults to
290 (i\&.e\&. keep the backup files)\&.
293 mergetool\&.keepTemporaries
295 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
296 \fBtrue\fR, then these temporary files will be preserved; otherwise, they will be removed after the tool has exited\&. Defaults to
300 mergetool\&.writeToTemp
306 versions of conflicting files in the worktree by default\&. Git will attempt to use a temporary directory for these files when set
307 \fBtrue\fR\&. Defaults to
313 Prompt before each invocation of the merge resolution program\&.
316 mergetool\&.guiDefault
321 \fBmerge\&.guitool\fR
322 by default (equivalent to specifying the
327 \fBmerge\&.guitool\fR
330 depending on the presence of a
332 environment variable value\&. The default is
333 \fBfalse\fR, where the
335 argument must be provided explicitly for the
336 \fBmerge\&.guitool\fR
339 .SH "TEMPORARY FILES"
341 \fBgit mergetool\fR creates \fB*\&.orig\fR backup files while resolving merges\&. These are safe to remove once a file has been merged and its \fBgit mergetool\fR session has completed\&.
343 Setting the \fBmergetool\&.keepBackup\fR configuration variable to \fBfalse\fR causes \fBgit mergetool\fR to automatically remove the backup files as files are successfully merged\&.
344 .SH "BACKEND SPECIFIC HINTS"
348 .nr an-no-space-flag 1
355 When specifying \fB\-\-tool=vimdiff\fR in \fBgit mergetool\fR Git will open Vim with a 4 windows layout distributed in the following way:
361 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
363 | LOCAL | BASE | REMOTE |
365 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
369 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
375 \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)
377 \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\&.
381 .nr an-no-space-flag 1
385 \fBLayout configuration\fR
388 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:
399 is used to "open a new tab"
411 is used to "open a new vertical split"
423 is used to "open a new horizontal split"
435 is used to indicate the file containing the final version after solving the conflicts\&. If not present,
437 will be used by default\&.
440 The precedence of the operators is as follows (you can use parentheses to change it):
446 `@` > `+` > `/` > `,`
452 Let\(cqs see some examples to understand how it works:
462 \fBlayout = "(LOCAL,BASE,REMOTE)/MERGED"\fR
464 This is exactly the same as the default layout we have already seen\&.
470 and thus the parenthesis are not needed in this case\&. The next layout definition is equivalent:
476 layout = "LOCAL,BASE,REMOTE / MERGED"
491 \fBlayout = "LOCAL,MERGED,REMOTE"\fR
493 If, for some reason, we are not interested in the
501 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
504 | LOCAL | MERGED | REMOTE |
507 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
522 \fBlayout = "MERGED"\fR
526 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\&.
532 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
538 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
553 \fBlayout = "@LOCAL,REMOTE"\fR
557 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\&.
563 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
571 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
586 \fBlayout = "LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE"\fR
588 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
590 \fBLOCAL\fR) and (\fBBASE\fR
592 \fBREMOTE\fR) respectively\&.
598 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
599 | <TAB #1> | TAB #2 | TAB #3 | |
600 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
602 | LOCAL | BASE | REMOTE |
604 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
608 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
618 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
619 | TAB #1 | <TAB #2> | TAB #3 | |
620 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
628 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
638 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
639 | TAB #1 | TAB #2 | <TAB #3> | |
640 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
648 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
663 \fBlayout = "LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE + (LOCAL/BASE/REMOTE),MERGED"\fR
665 Same as the previous example, but adds a fourth tab with the same information as the first tab, with a different layout\&.
671 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
672 | TAB #1 | TAB #2 | TAB #3 | <TAB #4> |
673 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
675 |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-| |
677 |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-| |
679 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
685 Note how in the third tab definition we need to use parentheses to make
693 .nr an-no-space-flag 1
700 Instead of \fB\-\-tool=vimdiff\fR, you can also use one of these other variants:
710 \fB\-\-tool=gvimdiff\fR, to open gVim instead of Vim\&.
721 \fB\-\-tool=nvimdiff\fR, to open Neovim instead of Vim\&.
724 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)\&.
726 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=[g,n,]vimdiffx\fR is the same as using \fB\-\-tool=[g,n,]vimdiff\fR and setting configuration variable \fBmergetool\&.[g,n,]vimdiff\&.layout\fR to\&...\:
737 \fB"@LOCAL, REMOTE"\fR
749 \fB"LOCAL, MERGED, REMOTE"\fR
764 Example: using \fB\-\-tool=gvimdiff2\fR will open \fBgvim\fR with three columns (LOCAL, MERGED and REMOTE)\&.
768 Part of the \fBgit\fR(1) suite