Back to all tips

Git Pro Tips

Squash Last Commits

🗓️ Published: 4/15/2026 Originally on X: 6/2/2022
Squash Last Commits

Squashing combines multiple commits into one. It improves readability and often makes rebasing easier.

To squash your last three commits:

git rebase -i HEAD~3

In the editor, keep the first line as pick and change the next ones to s, then save and exit.

Discuss this tip on