In order to delete all branches but master simply run the following command:

git checkout master
git branch | grep -v '^*' | xargs git branch -d