Mid Version Control

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

Follow:

them into one commit:

👉 Add responsive navbar component

✅ Pro Tip:

A clean workflow often looks like this:

More from Developer Essentials

All questions for this course