Why squash
A feature branch often accumulates "WIP", "fix typo", and "address review" commits that bury intent. Squashing condenses these into a small number of logically meaningful commits before merging. Reviewers see clean history; bisect works on real units of change.
Squash on merge
The simplest approach: let the merge collapse the branch:
git checkout main
git merge --squash feature
git commit -m "Add feature X"
This stages the cumulative diff and you write a single commit message. The downside: the branch's history is lost.