See squash merge compress a branch's messy wip commits into a single clean commit on main. Why it became the default PR merge style.
Scenario
Branch state
Current step 9/9
$ git merge --squash feature && git commit
Squash merge compresses all of feature into ONE commit on main. c3–c5 never enter main's history and the feature branch is usually deleted — that's why it's the default for PRs.
$ git log --oneline --all
c6 (HEAD -> main) Squash merge 'feature'
c2 base feature
c1 init
File content (at HEAD) — app.js @ main
Circles are commits; dimmed circles were abandoned by rebase/reset. A prime (c3') means same content, rewritten hash. In sandbox mode, run commands yourself with the buttons.
Squash merge compresses all of a branch's changes into a single commit on your current branch. However many wip, fix, typo commits feature accumulated, main's history gets exactly one 'add feature' commit.
The key difference from a real merge: the squash commit has only ONE parent. There's no history link to the merged branch, so feature's commits become unreachable — which is why the branch is usually deleted alongside.
That's why GitHub offers squash as a default PR merge mode. Review iterations leave messy fixup commits; squashing at merge time turns them into one clean entry. The tradeoff: the detailed per-commit history of the work is gone. Git Branch Simulator