World map

 

BM: Baca dalam Bahasa Melayu

World 3: Parallel Universes

Three-way merge

You will learn: how Git joins two branches that both moved on.

The problem

The log forks. main has Make heading teal. about has Add about page and Say what I like. Both grow from Add style. Terminal output: $ git log --oneline --graph --all * 01bb13d (HEAD -> main) Make heading teal | * 203a91f (about) Say what I like | * a20da6c Add about page |/ * 270a76e Add style * a8feb63 Add day 1 page * 6d3a9b1 Add README

This time main moved on too. The note can’t just slide forward. What will Git do?

Watch

A new commit appears on main. Two lines run into it: one from main, one from about.
6d3a9b1a8feb63270a76ea20da6c203a91f01bb13d

Git makes a new merge commit: A commit with two parents. It joins two branches.. It has two parents, one from each branch. Both stories join here.

Try it

Git compares three commits: your tip, their tip, and where they split. That spot is the merge base: The last commit two branches share: the spot where they split.. Find it.

Tap the last commit both branches share.

6d3a9b1a8feb63270a76ea20da6c203a91f01bb13d

Watch

git merge about prints: Merge made by the 'ort' strategy. Then about.html with 2 new lines. Terminal output: $ git merge about Merge made by the 'ort' strategy. about.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 about.html

Base, yours and theirs: three commits go in. That’s a three-way merge: Git compares both branch tips with their merge base, then joins them.. The word ort is the name of Git’s merge engine.

Try it

Your turn. You are on main. Merge about.

6d3a9b1a8feb63270a76ea20da6c203a91f01bb13d

Predict

How many parents does a merge commit have?

Pick one answer.

Check

Fast-forward, or a new merge commit?

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now merge branches that both moved on.

      Go deeper (optional)

      git show on a merge commit prints a Merge: line with both parents. git log --merges lists only merge commits. Git suggests the message Merge branch ‘about’. In a real terminal, your editor opens with it ready.

      git show HEAD on the merge: a Merge line with two short hashes, then the message Merge branch 'about'. Terminal output: $ git merge about Merge made by the 'ort' strategy. about.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 about.html $ git show HEAD commit 5a96d9e9064ee58d8f1105924df833a83948d2cf (HEAD -> main) Merge: 01bb13d 203a91f Author: You <you@example.com> Date: Fri Oct 30 09:07:00 2026 +0800 Merge branch 'about'