Created
September 17, 2018 10:28
-
-
Save CristianoPassos/1c374933ca44eba2c2c9fdbf3e8548a7 to your computer and use it in GitHub Desktop.
Remove 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
#!/bin/bash | |
MAIN=${1:-master} | |
BRANCHES=$(git branch --merged $MAIN | grep -v -e 'master\|staging\|development\|\*') | |
git pull | |
clear | |
echo Branches merged into $MAIN: | |
echo $BRANCHES | |
read -p "Delete these branches (y/n)? " answer | |
if [ "$answer" = "n" ]; then echo aborting && exit; fi | |
echo $BRANCHES | xargs -n 1 git branch -d | |
git fetch --prune |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment