Skip to content

Instantly share code, notes, and snippets.

@denisidoro
Created November 29, 2016 13:38
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 denisidoro/16c80b4768b2676d42eab64417abc055 to your computer and use it in GitHub Desktop.
Save denisidoro/16c80b4768b2676d42eab64417abc055 to your computer and use it in GitHub Desktop.
Prompt to delete each branch
#!/bin/sh
function prompt {
printf "Do you want to delete $1? (y/N)? "
read -r answer
if echo "$answer" | grep -iq "^y" ;then
git branch -D $1
fi
}
permanent=(master develop)
for branch in $(git branch | cut -c 3-) ; do
if ! [[ ${permanent[*]} =~ "$branch" ]]; then
prompt "$branch"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment