2 .\" Title: git-mergetool
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.45.0.rc0.3.g00e10ef10e
10 .TH "GIT\-MERGETOOL" "1" "2024\-04\-22" "Git 2\&.45\&.0\&.rc0\&.3\&.g00" "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>\&...]
40 Use \fBgit mergetool\fR to run one of several merge utilities to resolve merge conflicts\&. It is typically run after \fIgit merge\fR\&.
42 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\&.
45 \-t <tool>, \-\-tool=<tool>
47 Use the merge resolution program specified by <tool>\&. Valid values include emerge, gvimdiff, kdiff3, meld, vimdiff, and tortoisemerge\&. Run
48 \fBgit mergetool \-\-tool\-help\fR
49 for the list of valid <tool> settings\&.
51 If a merge resolution program is not specified,
53 will use the configuration variable
54 \fBmerge\&.tool\fR\&. If the configuration variable
58 will pick a suitable default\&.
60 You can explicitly provide a full path to the tool by setting the configuration variable
61 \fBmergetool\&.<tool>\&.path\fR\&. For example, you can configure the absolute path to kdiff3 by setting
62 \fBmergetool\&.kdiff3\&.path\fR\&. Otherwise,
64 assumes the tool is available in PATH\&.
66 Instead of running one of the known merge tool programs,
68 can be customized to run an alternative program by specifying the command line to invoke in a configuration variable
69 \fBmergetool\&.<tool>\&.cmd\fR\&.
73 is invoked with this tool (either through the
79 configuration variable), the configured command line will be invoked with
81 set to the name of a temporary file containing the common base for the merge, if available;
83 set to the name of a temporary file containing the contents of the file on the current branch;
85 set to the name of a temporary file containing the contents of the file to be merged, and
87 set to the name of the file to which the merge tool should write the result of the merge resolution\&.
89 If the custom merge tool correctly indicates the success of a merge resolution with its exit code, then the configuration variable
90 \fBmergetool\&.<tool>\&.trustExitCode\fR
92 \fBtrue\fR\&. Otherwise,
94 will prompt the user to indicate the success of the resolution after the custom tool has exited\&.
99 Print a list of merge tools that may be used with
105 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
109 configuration variable\&.
114 Prompt before each invocation of the merge resolution program to give the user a chance to skip the path\&.
125 option, the default merge tool will be read from the configured
126 \fBmerge\&.guitool\fR
128 \fBmerge\&.tool\fR\&. If
129 \fBmerge\&.guitool\fR
130 is not set, we will fallback to the tool configured under
131 \fBmerge\&.tool\fR\&. This may be autoselected using the configuration variable
132 \fBmergetool\&.guiDefault\fR\&.
137 This overrides a previous
142 \fBmergetool\&.guiDefault\fR
143 configuration and reads the default merge tool from the configured
150 Process files in the order specified in the <orderfile>, which has one shell glob pattern per line\&. This overrides the
151 \fBdiff\&.orderFile\fR
152 configuration variable (see
153 \fBgit-config\fR(1))\&. To cancel
154 \fBdiff\&.orderFile\fR, use
155 \fB\-O/dev/null\fR\&.
159 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:
161 mergetool\&.<tool>\&.path
163 Override the path for the given tool\&. This is useful in case your tool is not in the PATH\&.
166 mergetool\&.<tool>\&.cmd
168 Specify the command to invoke the specified merge tool\&. The specified command is evaluated in shell with the following variables available:
170 is the name of a temporary file containing the common base of the files to be merged, if available;
172 is the name of a temporary file containing the contents of the file on the current branch;
174 is the name of a temporary file containing the contents of the file from the branch being merged;
176 contains the name of the file to which the merge tool should write the results of a successful merge\&.
179 mergetool\&.<tool>\&.hideResolved
181 Allows the user to override the global
182 \fBmergetool\&.hideResolved\fR
183 value for a specific tool\&. See
184 \fBmergetool\&.hideResolved\fR
185 for the full description\&.
188 mergetool\&.<tool>\&.trustExitCode
190 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\&.
193 mergetool\&.meld\&.hasOutput
199 option\&. Git will attempt to detect whether
203 by inspecting the output of
204 \fBmeld \-\-help\fR\&. Configuring
205 \fBmergetool\&.meld\&.hasOutput\fR
206 will make Git skip these checks and use the configured value instead\&. Setting
207 \fBmergetool\&.meld\&.hasOutput\fR
210 tells Git to unconditionally use the
218 mergetool\&.meld\&.useAutoMerge
221 \fB\-\-auto\-merge\fR
222 is given, meld will merge all non\-conflicting parts automatically, highlight the conflicting parts, and wait for user decision\&. Setting
223 \fBmergetool\&.meld\&.useAutoMerge\fR
226 tells Git to unconditionally use the
227 \fB\-\-auto\-merge\fR
229 \fBmeld\fR\&. Setting this value to
231 makes git detect whether
232 \fB\-\-auto\-merge\fR
233 is supported and will only use
234 \fB\-\-auto\-merge\fR
235 when available\&. A value of
238 \fB\-\-auto\-merge\fR
239 altogether, and is the default value\&.
242 mergetool\&.<vimdiff variant>\&.layout
244 Configure the split window layout for vimdiff\(cqs
245 \fB<variant>\fR, which is any of
248 \fBgvimdiff\fR\&. Upon launching
251 \fB\-\-tool=<variant>\fR
257 \fB<variant>\fR), Git will consult
258 \fBmergetool\&.<variant>\&.layout\fR
259 to determine the tool\(cqs layout\&. If the variant\-specific configuration is not available,
260 \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
261 \fBBACKEND SPECIFIC HINTS\fR
265 mergetool\&.hideResolved
267 During a merge, Git will automatically resolve as many conflicts as possible and write the
269 file containing conflict markers around any conflicts that it cannot resolve;
273 normally represent the versions of the file from before Git\(cqs conflict resolution\&. This flag causes
277 to be overwritten so that only the unresolved conflicts are presented to the merge tool\&. Can be configured per\-tool via the
278 \fBmergetool\&.<tool>\&.hideResolved\fR
279 configuration variable\&. Defaults to
283 mergetool\&.keepBackup
285 After performing a merge, the original file with conflict markers can be saved as a file with a
287 extension\&. If this variable is set to
289 then this file is not preserved\&. Defaults to
291 (i\&.e\&. keep the backup files)\&.
294 mergetool\&.keepTemporaries
296 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
297 \fBtrue\fR, then these temporary files will be preserved; otherwise, they will be removed after the tool has exited\&. Defaults to
301 mergetool\&.writeToTemp
307 versions of conflicting files in the worktree by default\&. Git will attempt to use a temporary directory for these files when set
308 \fBtrue\fR\&. Defaults to
314 Prompt before each invocation of the merge resolution program\&.
317 mergetool\&.guiDefault
322 \fBmerge\&.guitool\fR
323 by default (equivalent to specifying the
328 \fBmerge\&.guitool\fR
331 depending on the presence of a
333 environment variable value\&. The default is
334 \fBfalse\fR, where the
336 argument must be provided explicitly for the
337 \fBmerge\&.guitool\fR
340 .SH "TEMPORARY FILES"
342 \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\&.
344 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\&.
345 .SH "BACKEND SPECIFIC HINTS"
349 .nr an-no-space-flag 1
356 When specifying \fB\-\-tool=vimdiff\fR in \fBgit mergetool\fR Git will open Vim with a 4 windows layout distributed in the following way:
362 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
364 | LOCAL | BASE | REMOTE |
366 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
370 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
376 \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)
378 \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\&.
382 .nr an-no-space-flag 1
386 \fBLayout configuration\fR
389 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:
400 is used to "open a new tab"
412 is used to "open a new vertical split"
424 is used to "open a new horizontal split"
436 is used to indicate the file containing the final version after solving the conflicts\&. If not present,
438 will be used by default\&.
441 The precedence of the operators is as follows (you can use parentheses to change it):
447 `@` > `+` > `/` > `,`
453 Let\(cqs see some examples to understand how it works:
463 \fBlayout = "(LOCAL,BASE,REMOTE)/MERGED"\fR
465 This is exactly the same as the default layout we have already seen\&.
471 and thus the parenthesis are not needed in this case\&. The next layout definition is equivalent:
477 layout = "LOCAL,BASE,REMOTE / MERGED"
492 \fBlayout = "LOCAL,MERGED,REMOTE"\fR
494 If, for some reason, we are not interested in the
502 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
505 | LOCAL | MERGED | REMOTE |
508 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
523 \fBlayout = "MERGED"\fR
527 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\&.
533 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
539 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
554 \fBlayout = "@LOCAL,REMOTE"\fR
558 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\&.
564 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
572 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
587 \fBlayout = "LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE"\fR
589 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
591 \fBLOCAL\fR) and (\fBBASE\fR
593 \fBREMOTE\fR) respectively\&.
599 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
600 | <TAB #1> | TAB #2 | TAB #3 | |
601 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
603 | LOCAL | BASE | REMOTE |
605 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
609 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
619 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
620 | TAB #1 | <TAB #2> | TAB #3 | |
621 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
629 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
639 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
640 | TAB #1 | TAB #2 | <TAB #3> | |
641 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
649 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
664 \fBlayout = "LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE + (LOCAL/BASE/REMOTE),MERGED"\fR
666 Same as the previous example, but adds a fourth tab with the same information as the first tab, with a different layout\&.
672 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
673 | TAB #1 | TAB #2 | TAB #3 | <TAB #4> |
674 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
676 |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-| |
678 |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-| |
680 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
686 Note how in the third tab definition we need to use parentheses to make
694 .nr an-no-space-flag 1
701 Instead of \fB\-\-tool=vimdiff\fR, you can also use one of these other variants:
711 \fB\-\-tool=gvimdiff\fR, to open gVim instead of Vim\&.
722 \fB\-\-tool=nvimdiff\fR, to open Neovim instead of Vim\&.
725 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)\&.
727 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\&...
738 \fB"@LOCAL, REMOTE"\fR
750 \fB"LOCAL, MERGED, REMOTE"\fR
765 Example: using \fB\-\-tool=gvimdiff2\fR will open \fBgvim\fR with three columns (LOCAL, MERGED and REMOTE)\&.
769 Part of the \fBgit\fR(1) suite