Skip to content

Instantly share code, notes, and snippets.

@kbingham
Last active December 5, 2016 12:05
Show Gist options
  • Save kbingham/b97d9a181e72191494619a9b46439ee4 to your computer and use it in GitHub Desktop.
Save kbingham/b97d9a181e72191494619a9b46439ee4 to your computer and use it in GitHub Desktop.
#!/bin/bash
## Derived from : http://stackoverflow.com/questions/2108405/branch-descriptions-in-git
## answered May 23 '13 at 9:21 ## jsageryd
# Shows branches with bases
function gb() {
branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
head=$(git rev-parse --abbrev-ref HEAD)
for branch in $branches; do
base=$(git describe --abbrev=0 $branch 2>/dev/null)
if [ $branch == $head ]; then
branch="* \033[0;32m$branch\033[0m"
else
branch=" $branch"
fi
echo -e "$branch \033[0;36m$base\033[0m"
done
}
gb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment