git --config push.default=matching push --force-with-lease --force-if-includes
In other words, I force push all branches that have a matching upstream by changing my config on the fly. git branch --merged "$(git config init.defaultBranch)" \
| grep -Fv "$(git config init.defaultBranch)" \
| grep -vF '*' \
| grep -vF '+' \
| xargs git branch -d \
&& git fetch \
&& git remote prune origin \
&& git branch -v \
| grep -F '[gone]' \
| grep -vF '*' \
| grep -vF '+' \
| awk '{print $1}' \
| xargs git branch -D
[1]: https://github.com/fphilipe/dotfiles/blob/ba9187d7c895e44c35...
https://github.com/fphilipe
[ my public key: https://keybase.io/philipe; my proof: https://keybase.io/philipe/sigs/182uf1x4SUnMvtmLchInbgTL0X0b0qcRGe_g2T0KLDo ]