Skip to content

Instantly share code, notes, and snippets.

@ldelelis
Created March 2, 2020 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldelelis/12f427162753fabc7d8136cc3f3877f3 to your computer and use it in GitHub Desktop.
Save ldelelis/12f427162753fabc7d8136cc3f3877f3 to your computer and use it in GitHub Desktop.
#!/bin/sh
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] "
REPLY=${REPLY:-"y"}
(echo $REPLY | grep -Eq ^[Yy]$) && echo $BRANCHES | while read branch; do
git branch -D $branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment