Skip to content

Instantly share code, notes, and snippets.

@phraemer
Created October 25, 2016 08:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phraemer/4cb3f83e008a0cd722086a670e26bc2f to your computer and use it in GitHub Desktop.
Save phraemer/4cb3f83e008a0cd722086a670e26bc2f to your computer and use it in GitHub Desktop.
Script deletes any merged remote branches after confirmation
#!/bin/bash
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]$ ]]
then
# do dangerous stuff
echo ${branchesToDelete} | xargs git branch -d
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment