Greetings, If you are like me, you get a lot of branches going, and trimming back takes too much time to check if they have been pushed, etc. etc. Here’s my attempt at a script. Obviously, my branches have bug_#### on them, and a few that don’t and obviously are unrelated to bugzilla. :) Enjoy, Mark Tompsett #!/bin/bash if [[ ! -d ~/bugs2check ]]; then echo "Creating report directory..." mkdir ~/bugs2check fi git checkout master BRANCH=`git status | grep "On branch" | cut -f3- -d' '` if [[ $BRANCH != "master" ]]; then echo "Handle your commits first." exit fi echo > ~/bugs2check/REPORT BUGS=`git branch | grep "bug_[0-9][0-9]*$" | cut -f2 -d'_' | sort -u` for i in `echo $BUGS`; do wget -O- http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=$i > ~/bugs2check/$i 2> /dev/null STATUS=`grep static_bug ~/bugs2check/$i | cut -f2 -d'>'` echo $i - $STATUS | tee -a ~/bugs2check/REPORT done BUGS2DEL=`grep 'Pushed to Master' ~/bugs2check/REPORT | cut -f1 -d' '` for i in `echo $BUGS2DEL`; do BRANCHES=`git branch | grep bug_$i` read -p "Delete $BRANCHES? " -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]]; then for j in `echo $BRANCHES`; do git branch -D $j done fi done BUGS2DEL=`grep 'Pushed to Stable' ~/bugs2check/REPORT | cut -f1 -d' '` for i in `echo $BUGS2DEL`; do BRANCHES=`git branch | grep bug_$i` read -p "Delete $BRANCHES? " -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]]; then for j in `echo $BRANCHES`; do git branch -D $j done fi done BUGS2DEL=`grep 'CLOSED' ~/bugs2check/REPORT | cut -f1 -d' '` for i in `echo $BUGS2DEL`; do BRANCHES=`git branch | grep bug_$i` read -p "Delete $BRANCHES? " -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]]; then for j in `echo $BRANCHES`; do git branch -D $j done fi done BUGS2DEL=`grep 'RESOLVED' ~/bugs2check/REPORT | cut -f1 -d' '` for i in `echo $BUGS2DEL`; do BRANCHES=`git branch | grep bug_$i` read -p "Delete $BRANCHES? " -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]]; then for j in `echo $BRANCHES`; do git branch -D $j done fi done