Created
October 8, 2019 17:21
-
-
Save mattc321/8a52c02f262121eabc66b5cf81df6cc9 to your computer and use it in GitHub Desktop.
Git Branch Cleaning House Function. Iterate through local brances and prompt for delete
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
function cb() { | |
git branch | grep -v "master\|staging" > ~/branches | |
GB=$'\e[32m' | |
RB=$'\e[31m' | |
E=$'\e[0m' | |
while read p | |
do | |
read -p "Delete branch ${GB}$p${E}? (y|N):" input < /dev/tty | |
if [ -z "$input" ] ; then | |
echo "..Skipping $p" | |
continue | |
fi | |
if [[ "$input" == "Y" ]] ; then | |
echo ${RB} | |
delBranch ${p} | |
echo ${E} | |
continue | |
else | |
echo "..Skipping $p" | |
continue | |
fi | |
done <~/branches | |
rm ~/branches | |
} | |
function delBranch() { | |
git branch -D $1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment