Let's say you want to rebase on master while squashing all your commits, and you have a clean working tree.
git fetch && \
git merge origin/master && \
git reset origin/master && \
git add --all && \
git commit -m "your new commit message"
- you fetch the latest updates from your remote
- you merge your rebase-target branch into your current branch, so the only diff between the two of them comes from your added commits
- you reset your branch to your target branch, erasing your commits while keeping your changes in the newly dirty working tree
- you add all those changes
- you create a new commit
This way you end up with a single fresh new commit on top of origin/master, and at most you dealt with conflicts only once.