What's the difference between git merge and git rebase?
⚡
Quick Answer
merge creates a merge commit preserving history; rebase replays your commits onto another base, producing linear history but rewriting commit hashes.
Detailed Answer
merge is non-destructive and keeps the true branching history. rebase makes history linear and easier to read but changes commit SHAs, so never rebase commits others have already pulled. A common workflow: rebase local feature work to tidy it, merge to integrate.
💡
Interview Tip
Golden rule: don't rebase shared/pushed history.
gitmergerebase