What exactly is a merge conflict?

You will have a conflict if you merge:

  • branch2 to master (no conflict)
  • branch3 to master (conflict):

That is because:

  • The common ancestor would be master (with a second line empty)
  • the source content is branch3 (with a second line including “3”)
  • the destination content is on latest of master (with a second line including “2”, from the merge of branch2 to master)

Git will ask you to choose which content to keep (“3”, “2”, or both).

First, do the merges after:

git config merge.conflictstyle diff3

See “Fix merge conflicts in Git?”.


Notes:

  • With Git 2.30 (Q1 2021), a new default merge strategy is in place: ORT (“Ostensibly Recursive’s Twin“), with clearer conflict messages (Gti 2.36, Q2 2022)

  • you can preview those conflicts with (Git 2.38, Q3 2022):

    git merge-tree --write-tree --no-messages branch1 branch2
    

    (That would not touch the index or working tree!)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)