SYNOPSIS
git mergetool [--tool=<tool>] [-y | --[no-]prompt] [<file>...]
DESCRIPTION
Use git mergetool to run one of several merge utilities to resolve merge conflicts. It is typically run after git merge.
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, git mergetool will run the merge tool program on every file with merge conflicts.
OPTIONS
-
-t<tool> -
--tool=<tool> -
Use the merge resolution program specified by <tool>. Valid values include
emerge,gvimdiff,kdiff3,meld,vimdiff, andtortoisemerge. Rungitmergetool--tool-helpfor the list of valid <tool> settings.If a merge resolution program is not specified,
gitmergetoolwill use the configuration variablemerge.tool. If the configuration variablemerge.toolis not set,gitmergetoolwill pick a suitable default.You can explicitly provide a full path to the tool by setting the configuration variable
mergetool.<tool>.path. For example, you can configure the absolute path to kdiff3 by settingmergetool.kdiff3.path. Otherwise,gitmergetoolassumes the tool is available in$PATH.Instead of running one of the known merge tool programs,
gitmergetoolcan be customized to run an alternative program by specifying the command line to invoke in a configuration variablemergetool.<tool>.cmd.When
gitmergetoolis invoked with this tool (either through the-tor--tooloption or themerge.toolconfiguration variable), the configured command line will be invoked withBASEset to the name of a temporary file containing the common base for the merge, if available;LOCALset to the name of a temporary file containing the contents of the file on the current branch;REMOTEset to the name of a temporary file containing the contents of the file to be merged, andMERGEDset to the name of the file to which the merge tool should write the result of the merge resolution.If the custom merge tool correctly indicates the success of a merge resolution with its exit code, then the configuration variable
mergetool.<tool>.trustExitCodecan be set totrue. Otherwise,gitmergetoolwill prompt the user to indicate the success of the resolution after the custom tool has exited. -
--tool-help -
--toolで使用できるマージツールのリストを出力します。 -
-y -
--no-prompt -
マージ解決プログラムを呼び出す前にプロンプトを表示しないでください。これは、マージ解決プログラムが
--toolオプションまたはmerge.tool構成変数で明示的に指定されている場合のデフォルトです。 -
--prompt -
マージ解決プログラムを呼び出す前にプロンプトを表示して、ユーザーにパス(path)をスキップする機会を与えます。
-
-g -
--gui -
When
git-mergetoolis invoked with the-gor--guioption, the default merge tool will be read from the configuredmerge.guitoolvariable instead ofmerge.tool. Ifmerge.guitoolis not set, we will fallback to the tool configured undermerge.tool. This may be autoselected using the configuration variablemergetool.guiDefault. -
--no-gui -
これは、 それ以前の
-gまたは--gui設定またはmergetool.guiDefault設定をオーバーライドし、 設定されたmerge.tool変数からデフォルトのマージ・ツールを読み取ります。 -
-O<orderfile> -
Process files in the order specified in the <orderfile>, which has one shell glob pattern per line. This overrides the
diff.orderFileconfiguration variable (see git-config(1)). To canceldiff.orderFile, use-O/dev/null.
CONFIGURATION
このセクションの以下のすべては、 git-config(1) ドキュメントの抜粋です。 内容は git-config(1) ドキュメント にあるものと同一です:
-
mergetool.<tool>.path -
指定のツール(<tool>)のパスを上書きします。 これは、ツールが
$PATH上にない場合に役立ちます。 -
mergetool.<tool>.cmd -
指定のマージツール(<tool>)を呼び出すコマンドを指定します。指定されたコマンドは、次の変数を使用してシェルで評価されます:
BASEは、マージされるファイルの共通ベースを含む一時ファイルの名前です(使用可能な場合)。LOCALは、現在のブランチのファイルの内容を含む一時ファイルの名前です。REMOTEは、マージされるブランチのファイルの内容を含む一時ファイルの名前です。MERGEDは、マージツールが正常なマージの結果を書き込むファイルの名前が含まれています。 -
mergetool.<tool>.hideResolved -
ユーザーが特定のツール(<tool>)のグローバルな
mergetool.hideResolved値をオーバーライドできるようにします。 詳細については、mergetool.hideResolvedを参照してください。 -
mergetool.<tool>.trustExitCode -
カスタム・マージ・コマンドの場合、 マージ・コマンドの終了コード(exit code)を使用してマージが成功したかどうかを判断できるかどうかを指定します。 これが true で無い場合、 マージ・ターゲット・ファイルのタイム・スタンプがチェックされ、 ファイルが更新されている場合はマージが成功したと見なされます。 そうでない場合、 ユーザーはマージの成功を示すようプロンプトを表示します。
-
mergetool.meld.hasOutput -
古いバージョンの
meldは--outputオプションをサポートしていません。 Gitは、meld--helpの出力を調べることで、meldが--outputをサポートしているかどうかを検出しようとします。mergetool.meld.hasOutputを設定すると、Gitはこれらのチェックをスキップし、代わりに設定された値を使用します。mergetool.meld.hasOutputをtrueに設定すると、Gitは無条件に--outputオプションを使用するようになり、falseは--outputの使用を回避します。 -
mergetool.meld.useAutoMerge -
meld は
--auto-mergeが指定されると、 競合していない全ての部分を自動的にマージし、 競合する部分を強調表示して、 ユーザーの決定を待ちます。mergetool.meld.useAutoMergeを`true` に設定すると、 Gitは--auto-mergeオプションをmeldで無条件に使用するようになります。 この値をautoに設定すると、 git は--auto-mergeがサポートされているかどうかを検出し、 使用可能な場合にのみ--auto-mergeを使用します。false値の場合、` --auto-merge` の使用を完全に回避します。 デフォルトはfalseです。 -
mergetool.<variant>.layout -
vimdiff のバリエーション(<variant>)である、
vimdiffやnvimdiffやgvimdiffのいずれかの分割ウィンドウ・レイアウトを構成します。--tool=<variant> を指定して(または、merge.toolが <variant> として設定されている場合は--tool無しで、)gitmergetoolを起動すると、 Git はmergetool.<variant>.layoutを参照してツールのレイアウトを決定します。 バリエーション固有の設定が利用できない場合は、vimdiffがフォールバックとして使用されます。 それも利用できない場合は、 4 つのウィンドウを含むデフォルトのレイアウトが使用されます。 レイアウトを構成するには「BACKEND SPECIFIC HINTS」セクションを参照してください。 -
mergetool.hideResolved -
マージ処理中、 Git は可能な限り多くの競合を自動的に解決し、 解決できない競合の周りに競合マーカーを含ませた
$MERGEDファイルを書き出します。$LOCALと$REMOTEは通常、 Git の競合解決前のファイルのバージョンを表します。 本設定により$LOCALと$REMOTEが上書きされ、 未解決の競合のみがマージ・ツールに表示されます。mergetool.<tool>.hideResolved構成変数を介してツールごとに構成できます。 デフォルトはfalseです。 -
mergetool.keepBackup -
マージを実行した後、競合マーカーを含む元のファイルを、拡張子
.origのファイルとして保存できます。 この変数がfalseに設定されている場合、このファイルは保存されません。 デフォルトはtrueです(つまり、バックアップファイルを保持します)。 -
mergetool.keepTemporaries -
カスタム・マージ・ツールを呼び出すとき、 Gitは一時ファイルの組をツールに渡します。 ツールがエラーを返し、 この変数が
trueに設定されている場合、 これらの一時ファイルは保持されます。 それ以外の場合、 これらの一時ファイルはツールの終了後に削除されます。 デフォルトはfalseです。 -
mergetool.writeToTemp -
Git は、デフォルトで、競合するファイルの一時的な
BASEバージョンと、LOCALバージョンと、REMOTEバージョンを、 ワークツリーに書き込みます。trueに設定すると、 Git はこれらのファイルに一時ディレクトリを使用しようとします。 デフォルトはfalseです。 -
mergetool.prompt -
マージ解決プログラムを呼び出す前にプロンプトを表示します。
-
mergetool.guiDefault -
trueを設定するとデフォルトでmerge.guitoolを使用します(引数--guiを指定するのと同じです)。 または、autoを設定するとDISPLAY環境変数値に応じてmerge.guitoolまたはmerge.toolを選択します。 デフォルトはfalseでmerge.guitoolを使用するには--gui引数を明示的に指定する必要があります。
TEMPORARY FILES
git mergetool は、マージの解決中に *.orig バックアップファイルを作成します。これらは、ファイルがマージされ、その git mergetool セッションが完了したら安全に削除できます。
mergetool.keepBackup 構成変数を false に設定すると、 git mergetool はファイルが正常にマージされた際にバックアップ・ファイルを自動的に削除します。
BACKEND SPECIFIC HINTS
vimdiff
Description
git mergetool で --tool=vimdiff を指定すると、Git は以下のように4つに分割されたウィンドウ・レイアウトで Vim を開きます:
------------------------------------------
| | | |
| LOCAL | BASE | REMOTE |
| | | |
------------------------------------------
| |
| MERGED |
| |
------------------------------------------
LOCALとBASEとREMOTEは、特定のコミットで競合するファイルの内容を示す読み取り専用バッファーです(それぞれ「マージ先のコミット」と「共通の祖先コミット」と「マージ元のコミット」)。
MERGED は、競合を解決する必要がある書き込み可能なバッファーです(他の読み取り専用バッファーを参照として使用します)。 完了したら、通常どおり Vim を保存して終了します(:wq)。中止する場合は、:cq を使用して終了します。
Layout configuration
以下の区切り文字が特別な意味を持つ文字列を受け入れる構成変数 mergetool.vimdiff.layout を設定することで、 Vim が使用するウィンドウ・レイアウトを変更できます:
-
+は「open a new tab」(新しいタブを開く)ために使用されます -
,は「open a new vertical split」(上下分割で開く)ために使用されます -
/は「open a new horizontal split」(左右分割で開く)ために使用されます -
@は、競合を解決した後の最終バージョンを含むファイルを示すために使用されます。 存在しない場合、デフォルトでMERGEDが使用されます。
演算子の優先順位は以下のとおりです(丸括弧(parentheses; ( … ))を使用して変更できます):
`@` > `+` > `/` > `,`
これがどのように機能するかを理解するためにいくつかの例を見てみましょう:
-
layout="(LOCAL,BASE,REMOTE)/MERGED"これは、すでに見たデフォルトのレイアウトとまったく同一です。
注意:
/は,よりも優先されるため、この場合は括弧は不要であることに注意してください。 つまり以下のレイアウト定義と同等です:layout = "LOCAL,BASE,REMOTE / MERGED" -
layout="LOCAL,MERGED,REMOTE"これは、もし、何らかの理由で
BASEバッファに関心がない場合です。------------------------------------------ | | | | | | | | | LOCAL | MERGED | REMOTE | | | | | | | | | ------------------------------------------ -
layout="MERGED"MERGEDバッファのみが表示されます。 ただし、他のすべてのものはまだvimにロードされており、buffersコマンドでアクセスできることに注意してください。------------------------------------------ | | | | | MERGED | | | | | ------------------------------------------ -
layout="@LOCAL,REMOTE"レイアウトに
MERGEDが表示されていない場合、 あなたが、 バッファのどれか1つをアットマーク(@)で「マーク」する必要があります。 これは、 競合を解決した後に編集して保存する必要があるバッファーになります(訳注: アットマーク(@) は at-sign(英)ではなく何故か arobase(仏)表記)。------------------------------------------ | | | | | | | | | | LOCAL | REMOTE | | | | | | | | | | ------------------------------------------ -
layout="LOCAL,BASE,REMOTE/MERGED+BASE,LOCAL+BASE,REMOTE"3つのタブが開かれます: 最初の 1 つはデフォルト・レイアウトのコピーで、残りの 2 つはそれぞれ (
BASEとLOCAL) と (BASEとREMOTE) の違いのみを示します。------------------------------------------ | <TAB #1> | TAB #2 | TAB #3 | | ------------------------------------------ | | | | | LOCAL | BASE | REMOTE | | | | | ------------------------------------------ | | | MERGED | | | ------------------------------------------------------------------------------------ | TAB #1 | <TAB #2> | TAB #3 | | ------------------------------------------ | | | | | | | | | | BASE | LOCAL | | | | | | | | | | ------------------------------------------------------------------------------------ | TAB #1 | TAB #2 | <TAB #3> | | ------------------------------------------ | | | | | | | | | | BASE | REMOTE | | | | | | | | | | ------------------------------------------ -
layout="LOCAL,BASE,REMOTE/MERGED+BASE,LOCAL+BASE,REMOTE+(LOCAL/BASE/REMOTE),MERGED"前の例と同一ですが、最初のタブと同じ情報を持つ 4 番目のタブを別のレイアウトで追加します。
--------------------------------------------- | TAB #1 | TAB #2 | TAB #3 | <TAB #4> | --------------------------------------------- | LOCAL | | |---------------------| | | BASE | MERGED | |---------------------| | | REMOTE | | ---------------------------------------------注意: 3 番目のタブ定義では、 丸括弧(parentheses; ( … ) ) を使用して
,を/よりも優先する必要があることに注意してください。
Variants
--tool=vimdiff の代わりに、これらの他のバリエーションのいずれかを使用することもできます:
-
--tool=gvimdiffは Vim の代わりに gVim を開きます。 -
--tool=nvimdiffは Vim の代わりに Neovim を開きます。
これらのバリエーションを使用する場合、カスタム・レイアウトを指定するには、構成変数 mergetool.vimdiff.layout の代わりに mergetool.gvimdiff.layout と mergetool.nvimdiff.layout を設定する必要があります(ただし、 そのバリエーション固有のものが設定されていない場合、 後者はフォールバックとして使用されます)。
さらに、以前の Git バージョンとの後方互換性を保つために、 vimdiff や、そのバリエーション (たとえば vimdiff3 、 nvimdiff1 等) の名前の後ろに 1 , 2 , 3 を追加して、定義済みのレイアウトを使用することも可能です。 言い換えると、 --tool=[g|n]vimdiff<x> を使用するということは、 --tool=[g|n]vimdiff を使用し、かつ、設定変数 mergetool.[g|n]vimdiff.layout を以下のように設定するのと同じことです。 (訳注: --tool=[g|n]vimdiff<x> → --tool=vimdiff1, --tool=vimdiff2, --tool=vimdiff3, --tool=gvimdiff1, --tool=gvimdiff2, --tool=gvimdiff3, --tool=nvimdiff1, --tool=nvimdiff2, --tool=nvimdiff3)
-
<x>
=1: "@LOCAL,REMOTE" -
<x>
=2: "LOCAL,MERGED,REMOTE" -
<x>
=3: "MERGED"
例: --tool=gvimdiff2 を使用すると、 gvim が 3 つの列(LOCAL, MERGED, REMOTE)で開きます。
GIT
Part of the git(1) suite