Skip to content

Instantly share code, notes, and snippets.

@TheBox193
Last active February 4, 2019 18:16
Show Gist options
  • Save TheBox193/3b0f3d87f72a598665c5623ae90952ec to your computer and use it in GitHub Desktop.
Save TheBox193/3b0f3d87f72a598665c5623ae90952ec to your computer and use it in GitHub Desktop.
Selectively bulk remove git branches
#!/bin/bash
if [ ! -d ".git" ]; then
echo "Not a git Directory"
exit 1
fi
git branch -d `git for-each-ref --format="%(refname:short)" refs/heads/\* |
while read -r line; do
read -p "remove branch: $line (y/N)?" answer </dev/tty;
case "$answer" in y|Y) echo "$line";;
esac;
done`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment