How do you squash commits in a PR before merging?
Short answer: Squashing combines multiple small commits into one clean commit before merging — keeping history tidy.
Explain a bit more
Options: On GitHub: When merging a PR, select “Squash and merge.” On local machine: git rebase -i HEAD~3 Change extra commits from pick → squash and then push with: git push -f Real-world example: If your PR has 10 commits like “fix typo,” “oops forgot semicolon,” and “final fix,” you squash them into one commit: 👉 Add responsive navbar component ✅ Pro Tip: A clean workflow often looks like this:
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