Skip to content

Instantly share code, notes, and snippets.

@andrewwheal
Created December 17, 2014 11:02
Show Gist options
  • Save andrewwheal/c881c026df934ca0cc9e to your computer and use it in GitHub Desktop.
Save andrewwheal/c881c026df934ca0cc9e to your computer and use it in GitHub Desktop.
git tidy-branches
#!/bin/bash
KEEP=$@
branches=$(git branch | grep -v "*" | grep -v "detached" | grep -v "no branch")
if [ "$KEEP" != "" ]; then
for notthis in $KEEP; do
branches=$(echo "$branches" | grep -vE "$notthis")
done
fi
for branch in $branches; do
git branch -D $branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment