Delete multiple remote branches in git

Use the following command to remove all branches with PREFIX prefix on remote server.

git branch -r | awk -F/ '/\/PREFIX/{print $2}' | xargs -I {} git push origin :{}

You may want to do a dry-run first to see if it is the branches that you want to remove:

git branch -r | awk -F/ '/\/PREFIX/{print $2}'

Leave a Comment