How do you rewrite commit history?
Short answer: (e.g., git rebase -i) You can interactively rebase to edit, squash, or reorder commits using: git rebase -i HEAD~3 This opens an editor showing the last 3 commits: pick 1a2b3c Fix typo in footer pick 4d5e6f Add login API pick 7g8h9i Update UI color scheme You can change: pick → edit to modify a commit pick → squash to combine commits pick → reword to change the message Real-world example: Before merging your feature…
Explain a bit more
branch, you may use git rebase -i to combine small “fix typo” or “debug print” commits into a clean, single commit. ⚠ Don’t rewrite history on shared branches that others are using — it can cause conflicts and confusion. GitHub & Remote Repository Management
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png