14. A merge starts from the common ancestor
Git finds the last commit both branches share, measures each tip's changes from it, applies both, and records a commit with two parents.

14. A merge starts from the common ancestor

Git finds the last commit both branches share, measures each tip's changes from it, applies both, and records a commit with two parents.

Knowing there is an ancestor explains why merges are usually clean and where conflicts come from.

Two branches, each with new commits. You want one result.

Git finds the last commit both branches share. The common ancestor.

Like two people who each copied one page and edited it. To combine them, compare each copy to the original. Not to each other.

Then it compares each tip to that ancestor. Two sets of changes. It applies both.

The result is a new commit with two parents. The merge commit.

Three photos go in. The ancestor, yours, theirs. That is why it is called a three way merge.

Check yourself. How many commits does a three-way merge read?

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime