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
This time main moved on too. The note can’t just slide forward. What will Git do?
Watch
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.
Watch
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.
Hint
Typegit merge about, then press Enter.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.
Bahasa Melayu
Kali ini main pun dah bergerak. Nota tak boleh sekadar meluncur ke depan. Apa Git akan buat?
Git buat merge commit baru. Ia ada dua induk, satu dari setiap branch. Dua cerita bertemu di sini.
Git banding tiga commit: hujung anda, hujung mereka, dan tempat ia berpecah. Tempat itu ialah merge base. Cari ia.
Asal, anda dan mereka: tiga commit masuk. Itulah merge tiga hala. Perkataan ort ialah nama enjin merge Git.
Giliran anda. Anda di main. Merge about.
git merge about, kemudian tekan Enter.Berapa induk yang merge commit ada?
Fast-forward, atau merge commit baru?
Kini anda boleh merge branch yang sama-sama dah bergerak.
You finished this before. Practice is always welcome!
Official docs: git merge · git merge-base
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?