Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 1 | git-mergetool(1) |
| 2 | ================ |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | git-mergetool - Run merge conflict resolution tools to resolve merge conflicts |
| 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
Junio C Hamano | 15567bc | 2011-07-23 00:51:59 | [diff] [blame] | 10 | [verse] |
Junio C Hamano | 3d1b5a1 | 2013-05-17 23:34:02 | [diff] [blame] | 11 | 'git mergetool' [--tool=<tool>] [-y | --[no-]prompt] [<file>...] |
Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 12 | |
| 13 | DESCRIPTION |
| 14 | ----------- |
| 15 | |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 16 | Use `git mergetool` to run one of several merge utilities to resolve |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 17 | merge conflicts. It is typically run after 'git merge'. |
Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 18 | |
| 19 | If one or more <file> parameters are given, the merge tool program will |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 20 | be run to resolve differences in each file (skipping those without |
Junio C Hamano | 5870066 | 2011-10-10 23:42:27 | [diff] [blame] | 21 | conflicts). Specifying a directory will include all unresolved files in |
| 22 | that path. If no <file> names are specified, 'git mergetool' will run |
| 23 | the merge tool program on every file with merge conflicts. |
Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 24 | |
| 25 | OPTIONS |
| 26 | ------- |
Junio C Hamano | bd53dbf | 2009-01-18 18:26:37 | [diff] [blame] | 27 | -t <tool>:: |
| 28 | --tool=<tool>:: |
Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 29 | Use the merge resolution program specified by <tool>. |
Junio C Hamano | 28a85be | 2012-07-24 22:05:15 | [diff] [blame] | 30 | Valid values include emerge, gvimdiff, kdiff3, |
| 31 | meld, vimdiff, and tortoisemerge. Run `git mergetool --tool-help` |
| 32 | for the list of valid <tool> settings. |
Junio C Hamano | 3aa8182 | 2007-03-30 08:52:26 | [diff] [blame] | 33 | + |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 34 | If a merge resolution program is not specified, 'git mergetool' |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 35 | will use the configuration variable `merge.tool`. If the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 36 | configuration variable `merge.tool` is not set, 'git mergetool' |
Junio C Hamano | 3aa8182 | 2007-03-30 08:52:26 | [diff] [blame] | 37 | will pick a suitable default. |
Junio C Hamano | 1c70883 | 2007-11-02 02:47:50 | [diff] [blame] | 38 | + |
| 39 | You can explicitly provide a full path to the tool by setting the |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 40 | configuration variable `mergetool.<tool>.path`. For example, you |
Junio C Hamano | 1c70883 | 2007-11-02 02:47:50 | [diff] [blame] | 41 | can configure the absolute path to kdiff3 by setting |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 42 | `mergetool.kdiff3.path`. Otherwise, 'git mergetool' assumes the |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 43 | tool is available in PATH. |
| 44 | + |
Junio C Hamano | ec87f52 | 2008-12-10 08:35:25 | [diff] [blame] | 45 | Instead of running one of the known merge tool programs, |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 46 | 'git mergetool' can be customized to run an alternative program |
Junio C Hamano | cb1c44f | 2008-08-06 06:19:33 | [diff] [blame] | 47 | by specifying the command line to invoke in a configuration |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 48 | variable `mergetool.<tool>.cmd`. |
| 49 | + |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 50 | When 'git mergetool' is invoked with this tool (either through the |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 51 | `-t` or `--tool` option or the `merge.tool` configuration |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 52 | variable), the configured command line will be invoked with `$BASE` |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 53 | set to the name of a temporary file containing the common base for |
| 54 | the merge, if available; `$LOCAL` set to the name of a temporary |
| 55 | file containing the contents of the file on the current branch; |
| 56 | `$REMOTE` set to the name of a temporary file containing the |
| 57 | contents of the file to be merged, and `$MERGED` set to the name |
| 58 | of the file to which the merge tool should write the result of the |
| 59 | merge resolution. |
| 60 | + |
| 61 | If the custom merge tool correctly indicates the success of a |
Junio C Hamano | ec87f52 | 2008-12-10 08:35:25 | [diff] [blame] | 62 | merge resolution with its exit code, then the configuration |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 63 | variable `mergetool.<tool>.trustExitCode` can be set to `true`. |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 64 | Otherwise, 'git mergetool' will prompt the user to indicate the |
Junio C Hamano | bb34317 | 2008-03-09 10:39:09 | [diff] [blame] | 65 | success of the resolution after the custom tool has exited. |
Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 66 | |
Junio C Hamano | a00504d | 2012-08-27 21:11:23 | [diff] [blame] | 67 | --tool-help:: |
| 68 | Print a list of merge tools that may be used with `--tool`. |
| 69 | |
Junio C Hamano | bd53dbf | 2009-01-18 18:26:37 | [diff] [blame] | 70 | -y:: |
| 71 | --no-prompt:: |
Junio C Hamano | 10b7a34 | 2009-01-01 22:05:17 | [diff] [blame] | 72 | Don't prompt before each invocation of the merge resolution |
| 73 | program. |
Junio C Hamano | b051caf | 2014-06-03 22:15:13 | [diff] [blame] | 74 | This is the default if the merge resolution program is |
| 75 | explicitly specified with the `--tool` option or with the |
| 76 | `merge.tool` configuration variable. |
Junio C Hamano | 10b7a34 | 2009-01-01 22:05:17 | [diff] [blame] | 77 | |
| 78 | --prompt:: |
Junio C Hamano | b051caf | 2014-06-03 22:15:13 | [diff] [blame] | 79 | Prompt before each invocation of the merge resolution program |
| 80 | to give the user a chance to skip the path. |
Junio C Hamano | 10b7a34 | 2009-01-01 22:05:17 | [diff] [blame] | 81 | |
Junio C Hamano | 94d00a5 | 2018-10-30 07:34:40 | [diff] [blame] | 82 | -g:: |
| 83 | --gui:: |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 84 | When 'git-mergetool' is invoked with the `-g` or `--gui` option, |
Junio C Hamano | 94d00a5 | 2018-10-30 07:34:40 | [diff] [blame] | 85 | the default merge tool will be read from the configured |
Junio C Hamano | 56d696e | 2019-05-19 09:01:19 | [diff] [blame] | 86 | `merge.guitool` variable instead of `merge.tool`. If |
| 87 | `merge.guitool` is not set, we will fallback to the tool |
Junio C Hamano | 4304bf6 | 2023-04-18 04:55:35 | [diff] [blame] | 88 | configured under `merge.tool`. This may be autoselected using |
| 89 | the configuration variable `mergetool.guiDefault`. |
Junio C Hamano | 94d00a5 | 2018-10-30 07:34:40 | [diff] [blame] | 90 | |
| 91 | --no-gui:: |
Junio C Hamano | 4304bf6 | 2023-04-18 04:55:35 | [diff] [blame] | 92 | This overrides a previous `-g` or `--gui` setting or |
| 93 | `mergetool.guiDefault` configuration and reads the default merge |
| 94 | tool from the configured `merge.tool` variable. |
Junio C Hamano | 94d00a5 | 2018-10-30 07:34:40 | [diff] [blame] | 95 | |
Junio C Hamano | c0859f7 | 2016-10-17 22:22:57 | [diff] [blame] | 96 | -O<orderfile>:: |
| 97 | Process files in the order specified in the |
| 98 | <orderfile>, which has one shell glob pattern per line. |
| 99 | This overrides the `diff.orderFile` configuration variable |
| 100 | (see linkgit:git-config[1]). To cancel `diff.orderFile`, |
| 101 | use `-O/dev/null`. |
| 102 | |
Junio C Hamano | 3692c01 | 2021-03-17 22:56:15 | [diff] [blame] | 103 | CONFIGURATION |
| 104 | ------------- |
Junio C Hamano | 84d4cc0 | 2022-05-11 00:55:58 | [diff] [blame] | 105 | :git-mergetool: 1 |
Junio C Hamano | ba8baee | 2022-09-14 20:25:23 | [diff] [blame] | 106 | |
| 107 | include::includes/cmd-config-section-all.txt[] |
| 108 | |
Junio C Hamano | 3692c01 | 2021-03-17 22:56:15 | [diff] [blame] | 109 | include::config/mergetool.txt[] |
| 110 | |
Junio C Hamano | afabd32 | 2010-07-19 20:26:15 | [diff] [blame] | 111 | TEMPORARY FILES |
| 112 | --------------- |
| 113 | `git mergetool` creates `*.orig` backup files while resolving merges. |
| 114 | These are safe to remove once a file has been merged and its |
| 115 | `git mergetool` session has completed. |
| 116 | |
| 117 | Setting the `mergetool.keepBackup` configuration variable to `false` |
Junio C Hamano | 33be821 | 2023-10-23 21:45:54 | [diff] [blame] | 118 | causes `git mergetool` to automatically remove the backup files as files |
Junio C Hamano | afabd32 | 2010-07-19 20:26:15 | [diff] [blame] | 119 | are successfully merged. |
| 120 | |
Junio C Hamano | 84d4cc0 | 2022-05-11 00:55:58 | [diff] [blame] | 121 | BACKEND SPECIFIC HINTS |
| 122 | ---------------------- |
| 123 | |
| 124 | vimdiff |
| 125 | ~~~~~~~ |
| 126 | include::mergetools/vimdiff.txt[] |
| 127 | |
Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 128 | GIT |
| 129 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 130 | Part of the linkgit:git[1] suite |