Last active
July 25, 2018 09:50
-
-
Save sod/d177620602d483bccfc28fe7251bf0f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git fetch -p | |
CURRENT=`git rev-parse --abbrev-ref HEAD` | |
if [ "$CURRENT" != "master" ]; then | |
git checkout master | |
fi | |
GONE=`git branch -vv | grep ": gone]" | awk '{print $1}'` | |
MERGED=`git branch --merge | grep -v '^*'` | |
echo | |
if [ "$GONE" != "" ]; then | |
echo "Delete GONE:" | |
echo | |
echo "$GONE" | |
fi | |
if [ "$MERGED" != "" ]; then | |
echo "Delete MERGED:" | |
echo | |
echo "$MERGED" | |
fi | |
if [ "$GONE" == "" ]; then | |
echo "Nothing to clean" | |
echo | |
exit 0 | |
fi | |
echo | |
echo "Continue?" | |
read | |
if [ "$MERGED" != "" ]; then | |
for branch in "$MERGED"; do | |
git branch -D $branch | |
done | |
fi | |
if [ "$GONE" != "" ]; then | |
for branch in "$GONE"; do | |
git branch -D $branch | |
done | |
fi | |
if [ "$CURRENT" != "master" ]; then | |
git checkout "$CURRENT" | |
fi | |
echo | |
echo Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment