Nine Genuinely Messy Real Commits
git log --oneline feature/index-cards -9
"WIP", "wip more", "asdf", "fix typo", "try again" — real, honest commit messages nobody would want in master's own permanent history.
Squashing the Entire Real Diff
git merge --squash feature/index-cards
git status
The entire real combined diff from all nine commits is staged as one unit — "Squash commit -- not updating HEAD" confirms no merge commit or branch history is being carried over yet.
One Real, Clean Commit
git commit -m "Add recipe index card storage guide"
One meaningful message, describing the real, finished result — none of the nine messy intermediate steps clutter master's history.
The Real Cost, Confirmed Directly
git branch -d feature/index-cards
warning: deleting branch 'feature/index-cards' that has been merged to
'refs/remotes/origin/feature/index-cards', but not yet merged to HEAD
A genuinely real warning: from git's own perspective, this branch's nine commits were never actually merged into master — only their squashed result was. The branch's own real history is gone the moment it's deleted.
feature/index-cards genuinely happened the way real work often does: nine commits, most of them vague, some of them outright unhelpful ("asdf", "try again"). The real content is fine — the commit history around it is not something master should inherit as-is.
git merge --squash takes the ENTIRE real diff the branch produced and stages it as one clean unit, letting you write one real, meaningful commit message for the whole thing. The real cost: the branch's own nine commits genuinely never become part of master's history — only their combined final result does.
git merge --squash
Stages the entire combined diff of a branch as one unit, without creating a merge commit or carrying over the branch's own commit history. Confirmed directly in this lab: "Squash commit -- not updating HEAD" appeared, and a single, real git commit afterward created exactly one new commit on master.
The real squash trade-off
Master gets one clean, meaningful commit instead of nine messy ones — genuinely better for anyone reading history later. The real cost: the branch's own nine commits are never part of master's ancestry, confirmed directly by git's own warning when later trying to delete the branch with plain -d.
Takeaways
- git merge --squash stages a branch's entire combined diff as one unit, without a merge commit or its own history
- The real trade-off: master gets one clean, meaningful commit, but the branch's own commit history never becomes part of it
- git itself confirms this honestly — a squash-merged branch triggers a real warning when deleted with plain -d
- Squash is a good real choice for messy exploratory work; destructive when the branch's own commits held separable value