I use
#!/bin/sh git checkout main git fetch --prune git branch | grep -v main | xargs --no-run-if-empty git branch -D git pull