Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created March 30, 2018 22:53
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 anaisbetts/79c142a28fb020b4b80f0ecb62831ab9 to your computer and use it in GitHub Desktop.
Save anaisbetts/79c142a28fb020b4b80f0ecb62831ab9 to your computer and use it in GitHub Desktop.
#!/bin/bash
git branch --merged | while read line
do
# If the line is in the format '* master' (indicating the current branch),
# this will be effectively empty, so we don't somehow delete the current
# branch
BRANCH=`echo "$line" | awk -F '*' '{ print $1 }'`
if [ -z "$BRANCH" ]
then
continue
fi
if [ "$BRANCH" == "master" ]
then
continue
fi
git branch -d "$BRANCH"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment