Day 3 - Merge vs rebase
This is Day 3 of DevOps Engineer Mastery. Today: a real conflict, abort, and when rebase is forbidden. Private branch only for rebase practice.
Words
A branch is a name on a commit. Branches diverge when each side adds commits after a common ancestor.
main: A---B
\
feature: C---D ancestor = B
Fast-forward slides the name. Merge commit is a new commit with two parents. Three-way merge needs ours + theirs + ancestor - that is why conflicts exist.
Rebase replays as new SHAs:
A---B---C'---D'
People who already pulled C and D still have the old IDs. That is why rebasing shared main is dangerous.
merge --abort / rebase --abort / rebase --continue (after add). Ours/theirs feel reversed on rebase - read the file, do not memorise a flag.
Practise
- Draw the graph first. If you cannot point at the ancestor, you are guessing.
- Create a real conflict. Merge it. Abort a merge once so you know the command exists.
- On a private branch only: rebase, hit a conflict, abort once, then continue correctly.
- Write one sentence: when rebase is forbidden.
Production
Do not rebase published default branches.
AI review (reject this)
Unread checkout --theirs .
Interview kill
Rebase main that twelve people already pulled.
Definition of done
You can draw diverge / ancestor / fast-forward / merge commit / rebase-as-new-SHAs. You created and aborted a conflict. You can say when rebase is forbidden without hedging.