A couple of team repos I work on have, over time, accumulated feature and integration branches which are no longer needed. Best practice is to clear these branches out once the code they contain is merged, but "the best laid schemes of mice and men..."
So I found myself facing a git repo with several dozen unneeded branches and no patience to clear them one at a time. The solution to the problem is the command below.
Warning : This command will destroy all but the branches named "master" and "develop" in your remote repo. Use with EXTREME care. If this were a Drupal module, it would have a dependency on Bad Judgement. If you use it and destroy the wrong branches, may $deity have mercy on your soul (because the other developers in the repo you nuke will not).
git branch -r | grep -v 'master\|develop' | cut -d"/" -f 2 | sed 's/^/git push origin :/' | bash