#!/bin/sh
set -eu
    
usage () {
    cat <<'EOF'
usage: git recent-branches [-h]

Shows a list of local branches, ordered by their date (most recent one first).

Options:
-h    Show this help
EOF
}

while getopts h flag; do
    case "$flag" in
        h) usage; exit 0;;
    esac
done

git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)'
