Rebase
ELI5 — The Vibe Check
Rebase is like rewriting history. Instead of merging branches (which creates a merge commit), rebase takes your changes and replays them on top of another branch, making it look like you started from the latest code all along. Cleaner history, but trickier.
Real Talk
Rebase moves or combines a sequence of commits to a new base commit. It rewrites commit history to create a linear sequence. Interactive rebase (-i) allows squashing, editing, or reordering commits. Never rebase commits that have been shared publicly.
Show Me The Code
git checkout feature
git rebase main
# Interactive rebase:
git rebase -i HEAD~3
When You'll Hear This
"Rebase your branch on main before merging." / "Don't rebase shared branches!"
Related Terms
Branch
A branch is like creating a parallel universe for your code.
Cherry-pick
Cherry-pick is like copying one specific change from another branch without merging everything.
Merge
Merge is like combining two parallel universes back into one. You take the changes from your branch and smoosh them into another branch.
Squash
Squash is like combining multiple save points into one.