How does a three-way merge work?
IntermediateConceptMerge, rebase and cherry-pick
Answer
Git finds the merge base (the best common ancestor), then compares each side against it. A hunk changed on only one side is taken automatically. A hunk changed on both sides differently is a conflict. This is why merging the same branch twice is safe: the new merge base is the previous merge commit.
git merge-base main feature
More on Merge, rebase and cherry-pick
What is the difference between a fast-forward merge and a merge commit?BeginnerWhat does `git rebase` actually do?IntermediateMerge versus rebase: how do you decide?IntermediateWhat are squash merge, merge commit and rebase-and-merge on GitHub?IntermediateWhy does a squash-merged branch show as unmerged to `git branch --merged`?IntermediateWhat does `git cherry-pick` do?Beginner