I make new branch from master with:
master
git checkout -b testbranch
I make 20 commits into it.
Now I want to squash those
What you're doing is pretty error-prone. Just do:
git rebase -i master
which will automatically rebase only your branch's commits onto the current latest master.