What is an interactive rebase used for?
⚡
Quick Answer
git rebase -i lets you reorder, squash, edit, or drop commits to clean up history before sharing.
Detailed Answer
Interactive rebase opens an editor listing commits with actions (pick, squash, reword, edit, drop). It's how you turn messy work-in-progress commits into a clean, reviewable series. Only do it on unpushed/private commits to avoid rewriting shared history.
Code Example
git rebase -i HEAD~5
💡
Interview Tip
Squashing WIP commits before a PR is the common motivation.
gitrebaseinteractive