Definition: combine multiple commits into one. More related to get tidy commits than a technical problem about not doing that.
You need to first figure out how many commits do you have to squash. To check that you can use:
git log
Imagine you wanna combine the last 3 commits into one. You'll do a soft reset from HEAD
minus 3 commits:
git reset --soft HEAD~3
After that you have all the files staged to commit (added like if you ran git add ...
), you need to do the combined commit:
git commit -m 'New message for the combined commit'
Now you have all the commits in one and you can push it to origin.
If you already created a pull request for example, you will have conflicts, so you may need to force push the commit using:
git push --force-with-lease