Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git: List recently changed branches
#!/bin/sh
OPTS_SPEC="\
git recent-branches [options]
--
days= Days to back (defaults 7)
date= Date format {relative,local,iso,rfc,short,raw,default}
no-merged Show only branches not merged into HEAD
"
eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
OPTIONS=''
while [ -n "$1" ]; do
case $1 in
"--days")
shift
DAYS="$1"
;;
"--date")
shift
DATE="$1"
;;
"--no-merged")
OPTIONS="$OPTIONS --not HEAD"
esac
shift
done
git log --date=${DATE-default} --remotes --simplify-by-decoration --no-merges \
--pretty='format:%C(blue)%ad%Creset %C(yellow)%H%Creset - %s %C(bold)[%an]%Creset' \
--since="{${DAYS-7} days ago}" \
$OPTIONS \
| git name-rev --stdin --name-only
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.