デフォルトのマージの場合、答えはイエスです。3 方向マージは、共通の祖先を見つけてから、両側からの違いを適用します。これは、順序に依存しない操作です。マージ順序付けと可換性のトピックは、git リストに関する興味深い議論を引き起こしました(その種のことに興味がある場合はそうです)。B into C
とは対称である必要がありますが、 vsC into B
については必ずしも同じとは言えません。(B into C) into A
B into (C into A)
[編集メモ、2020 年 4 月:-X ours
またはのようなオプションを追加する-X theirs
と、答えは「いいえ」になります。追加の注意事項については、 twalberg の回答とその他を参照してください。
以下のVinceのコメントと質問に関するsehのコメントに基づいて、もう少し詳しく説明すると、 と の間に2つの顕著な違いがB into C
ありC into B
、どちらも質問で参照されている自動マージ解決には影響しません。
まず歴史が違う。マージ コミットの親は、マージの順序によって変わります。これらの例では、「first_branch」と「second_branch」を使用して、コミットを表す文字を予約できるようにします。
git checkout first_branch && git merge second_branch
E <- merge commit
|\
| D <- second_branch's tip
| |
| C <- another commit on second_branch
| |
| B <- and another
|/
A <- first_branch's tip before the merge
この場合、E, の「最初の親」はE^1
、マージ前の first_branch のヒントです。second_branch は、マージ コミットの「2 番目の親」、つまりE^2
です。逆を考えてみましょう:
git checkout second_branch && git merge first_branch
E <- merge commit
|\
| D <- first_branch's tip
| |
| C <- another commit on first_branch
| |
| B <- and another
|/
A <- second_branch's tip before the merge
両親が逆です。E^1
マージ前の second_branch の先端です。E^2
first_branch の先端です。
次に、競合の表示順序が逆になります。最初のケースでは、競合は次のようになります。
<<<<<<< HEAD
This line was added from the first_branch branch.
=======
This line was added from the second_branch branch.
>>>>>>> second_branch
2 番目のケースでは、同じ競合は次のようになります。
<<<<<<< HEAD
This line was added from the second_branch branch.
=======
This line was added from the first_branch branch.
>>>>>>> first_branch
これらの違いはどちらも自動マージ解決には影響しませんが、3 者間マージ順序を逆にすると表示されます。