Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
See all git branches with descriptions and last commit date
#!/bin/bash
# Shows branches with descriptions
branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
for branch in $branches; do
last_used=$(git show --pretty=format:"%Cgreen%cr%Creset" $branch | head -1)
desc=$(git config branch.$branch.description)
if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then
branch="*\t$last_used\t\033[0;32m$branch\033[0m"
else
branch="\t$last_used\t$branch"
fi
echo -e "$branch \033[0;36m$desc\033[0m"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment