To squash all your commits and 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"
Note: finding that origin branch isn't easy/possible with Git.
but the above method is not a perfect one because it has a list, where the branch is coming.
so there is a way for that you will need to use:
git push --force
For the reset, you can do
git reset $(git merge-base master $(git rev-parse --abbrev-ref HEAD))
it automatically uses the branch you are currently on.