Created
May 26, 2012 09:44
-
-
Save Crash--/2793164 to your computer and use it in GitHub Desktop.
Remove all merged branch. Be careful if you have merged a branch into the master and continue to work on it and then you haven't merged it yet, this script will remove it.
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
git checkout master | |
git fetch | |
git remote prune origin | |
#Remove locally | |
git branch --merged master | grep -v 'master$' | xargs git branch -d | |
echo "Branches merged, to delete:" | |
git branch -r --merged master | sed 's/ *origin\///' | grep -v 'master$' | |
read -p "Sure about that (y/n)? " | |
if [ "$REPLY" == "y" ] | |
then | |
#Remove remotely | |
git branch -r --merged master | sed 's/ *origin\///' \ | |
| grep -v 'master$' | xargs -I% git push origin :% | |
echo "Done!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment