Lesson 14 / 26
What Rebase Does
Replaying commits onto a new base instead of merging histories.
Rebase onto main
This replays your branch's commits on top of the latest main, one by one, instead of creating a merge commit.
git switch feature/login
git rebase main
Output:
Successfully rebased and updated refs/heads/feature/login.
Rebase vs merge
Merge preserves history exactly as it happened, with branches visible. Rebase rewrites commit history into a straight, linear line — cleaner to read, but the commits get new hashes.
Never rebase shared history
Since rebase rewrites commits, never rebase a branch that others have already pulled — it forces everyone to fix their history. Rebase only your own unpushed local work.