Last Updated: February 25, 2016
·
392
· lbain

Print last commit message for each branch

I love git branches. A lot. I also hate deleting things. So I usually end up with a bunch of branches sitting around. And then some of the branches are so old I've forgotten what they do. (I absolutely agree that's a sign that I should name my branches better and that I should trim extra/merged branches more regularly. But given that I haven't gotten into that habit just yet...)

I wrote a little command to print out each branch name (in green for better readability) and the most recent commit message for that branch.

for k in $(git branch |grep -v "\->"|sed s/^..//);do
    echo -e "\033[32m $k \033[0m";
    echo -e $(git log -1 --pretty=format:"\\t %s" "$k")
done

You can change the

git log -1 --pretty=format:"\\t %s" "$k"

to be anything you want to know about that branch, where $k is the branch name