Skip to content

Instantly share code, notes, and snippets.

Created October 25, 2016 08:06
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save phraemer/4cb3f83e008a0cd722086a670e26bc2f to your computer and use it in GitHub Desktop.
Script deletes any merged remote branches after confirmation
branchesToDelete=`git branch --merged | egrep -v "(^\*|master)"`
echo "The following branches will be deleted..."
echo ${branchesToDelete}
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
# do dangerous stuff
echo ${branchesToDelete} | xargs git branch -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment