Boss lesson · Unit 02
Merge or rebase
Replay commits on a new base, and know when not to
What you practise
- Rebase replays commits onto a new base and gives them new hashes
- Linear history vs true history
- The rule about rebasing shared branches
- Interactive rebase in outline
Try a question from this lesson
Pick one
You want feature's work to sit on top of e, as if you had started it today. A commit's parent is part of the commit. What must happen to c and d?
a --- b --- e main
\
c --- d featureCorrect answer
They are re-created as new commits on top of e
Why
A commit can never be edited, and its parent is part of its content. So git replays each change as a brand-new commit: a new c on top of e, then a new d on top of that. Same changes, new parents, new hashes.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Replay, not move
Rebase takes the commits that are on your branch but not on the target and replays them, one by one, on top of the target.
The replayed commits are new objects with new hashes. The originals are not deleted: they just have no branch pointing at them any more.
before after
a - b main a - b main
\ \
c - d feature c' - d' feature11 more exercises in the app
- 4× type the answer
- 3× multiple choice
- 1× true or false
- 1× fill the blanks
- 1× order the lines
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.