So, here at work we have lots of people working in lots of branches. Sometimes, branches are merged into our master and people forget to remove them from the remote.
So I've made a little script to show me when was the last activity on each branch; Just alias the code below to some functions (or create an executable in your path so you can run it from any repo you have on your machine)
for branch in `git branch -a`; do; if [ $branch != "*" ]; then; hasAct=$(git log --abbrev-commit --date=relative -1 $branch); lastActivity=$(echo "$hasAct" | grep Date: | sed 's/Date: //'); echo "$branch last activity was\033[1;31m$lastActivity\033[0m"; echo "" fi; done;
You will get something like the output below:
From there, you can see wich branch hasn't been update in a while and delete if you want.
I have another version wich shows me only the branches that have not been updated for the past 15 days. You could automate the deletion of those branches or send yourself a report via e-mail... Anyway, hope you guys liked the tip :)