Skip to content

Instantly share code, notes, and snippets.

@mattc321
Created October 8, 2019 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattc321/8a52c02f262121eabc66b5cf81df6cc9 to your computer and use it in GitHub Desktop.
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
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