Skip to content

Instantly share code, notes, and snippets.

@remyoudemans
Created October 30, 2019 10:35
Show Gist options
  • Save remyoudemans/e846f982e9b114690b5dacc38415639d to your computer and use it in GitHub Desktop.
Save remyoudemans/e846f982e9b114690b5dacc38415639d to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
green='\033[0;32m'
NC='\033[0m' # No Color
branches=()
eval "$(git for-each-ref --shell --format='branches+=(%(refname))' refs/heads/)"
for branch in "${branches[@]}"; do
branch="$(echo $branch | cut -d/ -f3-)"
echo -e "Branch to delete: $green$branch$NC"
read -p "Delete? (y/N)" -n 1
if [[ $REPLY == "y" ]]; then
echo
echo "...................deleting"
git branch -d $branch
else
echo "skipping"
fi
echo
done
echo 'All done!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment