Enter an interactive rebase session:

git rebase -i <commit id to start after>

In interactive mode, replace pick with squash for the commits to squash.