🔀Squash Merge
Also known as Squash and Merge, Squash Commits, git merge --squash
Merging a branch as one commit. Main's history stays short.
Think of it like
Think of it like packing lots of small bags into one big case. Then you carry just one.
Example
Lucy's branch has twelve small commits. She squash-merges it, and main gets one commit: Add a dark mode switch.
Why it matters
Main shows one commit per feature. That is easy to read and easy to undo.
Definition
Example code
bash
git switch main
git merge --squash add-dark-mode
git commit -m "Add a dark mode switch"Common mistake
Key takeaways
- 1Many become one. All commits are squashed together.
- 2Clean main. One commit for each feature.
- 3Start fresh after. Make a new branch for new work.