Git: simplest way of squashing commits on master [duplicate]

Before starting, you should make sure that git status is clean (i.e. there's no output from that command) to avoid losing work. The simplest way to do what you want is probably:

git reset --soft <LAST-COMMIT-THAT'S-OK>
git commit -m 'Many squashed commits'
git push --force origin master

You should bear in mind that this is rewriting history (that's why you need the --force option to git push) so you should avoid this if anyone else might have cloned or pulled from your repository. For some more alternatives, see this question and its answers:

  • Squash my last X commits together using Git