Created
December 27, 2011 21:19
-
-
Save jraines/1525193 to your computer and use it in GitHub Desktop.
Go through your remote branches that contain some substring (or prefix) and prompt for deletion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo 'Clean up branches containing: ' | |
read prefix | |
while read line; do | |
branch=$(echo $line | sed 's/origin\///') | |
echo "Delete this $line? [y/n]" | |
#can't just read from stdin while inside loop | |
read answer </dev/tty | |
if [ "$answer" == "y" ]; then | |
$(git push origin :$branch) | |
else | |
echo "skipped $line" | |
fi | |
done <<< "$(git branch -r | grep $prefix)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment