To squash the last n commits into a single commit, we can use:
git reset -- soft HEAD~n &&
git commit