Created
May 31, 2019 16:48
-
-
Save aloverso/b35638f39c6d8e7543a266ccd126f885 to your computer and use it in GitHub Desktop.
Delete merged git branches
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
#!/usr/bin/env bash | |
git checkout master | |
git fetch -p | |
echo "" | |
echo "THIS SCRIPT WILL DELETE THESE BRANCHES:" | |
echo "---------------------------------------" | |
git branch --merged master | grep -v "\*" | |
echo "" | |
echo -n "Do you want to proceed (y/n)?" | |
read answer | |
if echo "$answer" | grep -iq "^y" ;then | |
git branch --merged master | grep -v "\*" | xargs -n 1 git push --delete origin | |
git branch --merged master | grep -v "\*" | xargs -n 1 git branch -d | |
echo "" | |
echo "Enjoy your new cleanliness!" | |
else | |
echo "" | |
echo "Fine, clean it yourself" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment