🗜️ CHAPTER · GIT SQUASH
Chef You

Compress Messy
History

Five "WIP" commits? Three "fix typo" commits? Squash them into one clean, meaningful commit before merging. Tidy history, happy team.

Scene I

The messy history

Chef You

Your feature branch has 6 commits that should really be one:

"WIP", "fix typo", "oops forgot file", "actually fix it", "lint fix", "final version"

Squash combines them all into a single, clean commit with a proper message. Use git merge --squash or git rebase -i.

🗜️ SQUASH PRESS See the messy commits. Press squash!
📋 BEFORE (6 commits)
squash
✨ AFTER (1 commit)
Squashed!

🎉 6 became 1

One clean commit with a proper message. The messy WIP commits are gone. Your PR reviewers will thank you.

When to squash: before merging feature branches, cleaning up "fix typo" chains, or combining related small changes.

$ git rebase -i HEAD~6
pick a1b2c3d WIP: start feature
squash b2c3d4e Fix typo
squash c3d4e5f Forgot file
squash d4e5f6g Actually fix it
→ 1 commit: "Add glaze feature"
Epilogue
Squash your mess before merging.
One clean commit beats
ten sloppy ones.

Most teams use "Squash and Merge" on GitHub PRs — it squashes automatically when merging a pull request.