From here.
Run git config --global --edit
and add the following under the [alias]
section.
squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
You can now "squash" commits together by using e.g.: git squash 3