Skip to content

Instantly share code, notes, and snippets.

@motemen
Created November 28, 2012 10:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motemen/4160297 to your computer and use it in GitHub Desktop.
Save motemen/4160297 to your computer and use it in GitHub Desktop.
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