Skip to content

Instantly share code, notes, and snippets.

@benauthor
Last active November 27, 2018 15:03
Show Gist options
  • Save benauthor/d9e899266841e409a32a2cac8a3f1df0 to your computer and use it in GitHub Desktop.
Save benauthor/d9e899266841e409a32a2cac8a3f1df0 to your computer and use it in GitHub Desktop.
#!/bin/bash
args="--merged"
echo "delete some merged branches:"
{ git branch $args | grep -E -v "master|stable|prod|\*" | cut -c 3- | while read -r branchname; do
read -r -u 3 -p "Delete $branchname (y/n)? " answer
case ${answer:0:1} in
y|Y )
git branch -d "$branchname"
;;
* )
echo "$branchname not deleted"
;;
esac
done } 3<&0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment