Rebase
A merge joins two histories and leaves the fork visible forever. A rebase does something different: it replays your commits on top of the other branch, as if you had started from there all along.
The result is a straight line instead of a fork. But notice what it costs — the replayed commits are brand new commits with new ids. The originals are left behind.
That is why the rule of thumb is: rebase your own unshared work, merge when others already have the commits.
Exercises
- Exercise 1. main and feature have each moved on. Rebase feature onto main so its commit replays on top of main's tip.
- Exercise 2. feature now has two commits of its own. Rebase again — both get replayed, in order, and both get new ids.