How to squash already pushed commits

When working on a pull requests it happens more often then not, that you have to push multiple commits to one pull request. Of course you don't want to have all of them in the master, so what do you do? You squash them. That's not problem locally, but just a little more difficult on a remote. Here is how to (example for squashing the last 5 commits):

Squashing:

$ git rebase -i origin/master~5 master

Pushing:

$ git push origin +master

You can find more information about why to use + instead of --force in the git push documentation.