Mid
From PDF
Version Control
Git & GitHub
How do you squash commits in a PR before merging?
Squashing combines multiple small commits into one clean commit before merging —
keeping history tidy.
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:
clean workflow often looks like this:
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png