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/>
10 .TH "GIT\-MERGETOOL" "1" "2023\-06\-01" "Git 2\&.41\&.0" "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 on 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 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\&.layout
244 The vimdiff backend uses this variable to control how its split windows look like\&. Applies even if you are using Neovim (\fBnvim\fR) or gVim (\fBgvim\fR) as the merge tool\&. See BACKEND SPECIFIC HINTS section for details\&.
247 mergetool\&.hideResolved
249 During a merge Git will automatically resolve as many conflicts as possible and write the
251 file containing conflict markers around any conflicts that it cannot resolve;
255 normally represent the versions of the file from before Git\(cqs conflict resolution\&. This flag causes
259 to be overwritten so that only the unresolved conflicts are presented to the merge tool\&. Can be configured per\-tool via the
260 \fBmergetool\&.<tool>\&.hideResolved\fR
261 configuration variable\&. Defaults to
265 mergetool\&.keepBackup
267 After performing a merge, the original file with conflict markers can be saved as a file with a
269 extension\&. If this variable is set to
271 then this file is not preserved\&. Defaults to
273 (i\&.e\&. keep the backup files)\&.
276 mergetool\&.keepTemporaries
278 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
279 \fBtrue\fR, then these temporary files will be preserved, otherwise they will be removed after the tool has exited\&. Defaults to
283 mergetool\&.writeToTemp
289 versions of conflicting files in the worktree by default\&. Git will attempt to use a temporary directory for these files when set
290 \fBtrue\fR\&. Defaults to
296 Prompt before each invocation of the merge resolution program\&.
299 mergetool\&.guiDefault
304 \fBmerge\&.guitool\fR
305 by default (equivalent to specifying the
310 \fBmerge\&.guitool\fR
313 depending on the presence of a
315 environment variable value\&. The default is
316 \fBfalse\fR, where the
318 argument must be provided explicitly for the
319 \fBmerge\&.guitool\fR
322 .SH "TEMPORARY FILES"
324 \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\&.
326 Setting the \fBmergetool\&.keepBackup\fR configuration variable to \fBfalse\fR causes \fBgit mergetool\fR to automatically remove the backup as files are successfully merged\&.
327 .SH "BACKEND SPECIFIC HINTS"
331 .nr an-no-space-flag 1
338 When specifying \fB\-\-tool=vimdiff\fR in \fBgit mergetool\fR Git will open Vim with a 4 windows layout distributed in the following way:
344 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
346 | LOCAL | BASE | REMOTE |
348 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
352 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
358 \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)
360 \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\&.
364 .nr an-no-space-flag 1
368 \fBLayout configuration\fR
371 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:
382 is used to "open a new tab"
394 is used to "open a new vertical split"
406 is used to "open a new horizontal split"
418 is used to indicate which is the file containing the final version after solving the conflicts\&. If not present,
420 will be used by default\&.
423 The precedence of the operators is this one (you can use parentheses to change it):
429 `@` > `+` > `/` > `,`
435 Let\(cqs see some examples to understand how it works:
445 \fBlayout = "(LOCAL,BASE,REMOTE)/MERGED"\fR
447 This is exactly the same as the default layout we have already seen\&.
453 and thus the parenthesis are not needed in this case\&. The next layout definition is equivalent:
459 layout = "LOCAL,BASE,REMOTE / MERGED"
474 \fBlayout = "LOCAL,MERGED,REMOTE"\fR
476 If, for some reason, we are not interested in the
484 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
487 | LOCAL | MERGED | REMOTE |
490 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
505 \fBlayout = "MERGED"\fR
509 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\&.
515 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
521 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
536 \fBlayout = "@LOCAL,REMOTE"\fR
540 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\&.
546 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
554 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
569 \fBlayout = "LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE"\fR
571 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
573 \fBLOCAL\fR) and (\fBBASE\fR
575 \fBREMOTE\fR) respectively\&.
581 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
582 | <TAB #1> | TAB #2 | TAB #3 | |
583 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
585 | LOCAL | BASE | REMOTE |
587 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
591 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
601 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
602 | TAB #1 | <TAB #2> | TAB #3 | |
603 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
611 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
621 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
622 | TAB #1 | TAB #2 | <TAB #3> | |
623 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
631 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
646 \fBlayout = "LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE + (LOCAL/BASE/REMOTE),MERGED"\fR
648 Same as the previous example, but adds a fourth tab with the same information as the first tab, with a different layout\&.
654 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
655 | TAB #1 | TAB #2 | TAB #3 | <TAB #4> |
656 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
658 |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-| |
660 |\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-| |
662 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
668 Note how in the third tab definition we need to use parenthesis to make
676 .nr an-no-space-flag 1
683 Instead of \fB\-\-tool=vimdiff\fR, you can also use one of these other variants:
693 \fB\-\-tool=gvimdiff\fR, to open gVim instead of Vim\&.
704 \fB\-\-tool=nvimdiff\fR, to open Neovim instead of Vim\&.
707 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
709 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\&...
720 \fB"@LOCAL, REMOTE"\fR
732 \fB"LOCAL, MERGED, REMOTE"\fR
747 Example: using \fB\-\-tool=gvimdiff2\fR will open \fBgvim\fR with three columns (LOCAL, MERGED and REMOTE)\&.
751 Part of the \fBgit\fR(1) suite