What Rebase Does
Replaying commits.
You know merge. It joins two branches with a merge commit. Rebase is the other way to bring branches together. Instead of joining them, it moves your branch, so it starts from the latest commit on main.

- Merge joins branches
- Rebase moves your branch
- Onto the tip of main
Before and after rebase
Here's our feature branch, with two commits, F1 and F2. Meanwhile, main got a new commit, M. Rebasing the feature onto main takes F1 and F2, and replays them, one by one, on top of M. They become new commits, with new hashes. The old ones are left behind. Now the feature starts from the latest main.
Merge versus rebase
Merge never changes existing commits. It's safe and honest, but adds merge commits. Rebase rewrites your branch's commits, giving a clean, straight history. Both are useful. The secret is knowing when rebase is safe, and we'll cover that in a moment.
Merge
- Keeps commits as they are
- Adds a merge commit
Rebase
- Rewrites your commits
- Straight, clean history
Summary
Rebase replays your commits on top of another branch, creating new commits with new hashes. Next, doing it for real.
Key takeaways- Rebase = replay commits
- New hashes
- Straight history