Skip to content

Instantly share code, notes, and snippets.

Created Mar 2, 2020
What would you like to do?
set -e
echo "Updating remote state"
git fetch --prune
BRANCHES=$(git branch -vv | grep -e 'gone]' | awk '{ print $1 }')
echo "Branches to delete locally:"
echo $BRANCHES | tr ' ' '\n'
read -p "Is this correct? Confirming will locally delete the listed branches! [Y/n] "
(echo $REPLY | grep -Eq ^[Yy]$) && echo $BRANCHES | while read branch; do
git branch -D $branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment