I have a team member who inadvertently pushed over 150 of his local branches to our central repo. Thankfully, they all have the same prefix. Using that prefix, is there a gi
Thanks to Neevek for great and elegant solution!
But i have some troubles with slashes in branch names (i'm using Git Flow), because of awk field separator / (-F option)
So my solution is based on Neevek's, but correctly parses branch names with /. In this case i presume that your remote called origin.
Command for deleting remote branches with names staring with PATTERN:
git branch -r | awk -Forigin/ '/\/PATTERN/ {print $2}' | xargs -I {} git push origin :{}
And don't forget to check what you are going to delete:
git branch -r | awk -Forigin/ '/\/PATTERN/ {print $2}'
USEFUL TIP: If your branch names (without origin/ prefix) stored in a text file (one branch name per line), just run:
cat your_file.txt | xargs -I {} git push origin :{}