I make new branch from
git checkout -b testbranch
git rebase -i HEAD~20
git rebase -i all on this branch
Another way to squash all your commits is to reset the index to master:
git checkout yourBranch git reset $(git merge-base master yourBranch) git add -A git commit -m "one commit on yourBranch"
This isn't perfect as it implies you know from which branch "yourBranch" is coming from.
Note: finding that origin branch isn't easy/possible with Git (the visual way is often the easiest, as seen here).