I make new branch from master with:
master
git checkout -b testbranch
I make 20 commits into it.
Now I want to squash those
You can use tool I've created specifically for this task:
https://github.com/sheerun/git-squash
Basically you need to call git squash master and you're done
git squash master