Created
November 6, 2013 20:30
-
-
Save lmarlow/7343546 to your computer and use it in GitHub Desktop.
Prints the branches with the most recent commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################# | |
usage () { | |
printf "%s" "\ | |
usage: git recent [-r remote] [count] | |
Prints the branches with the most recent commits. | |
options: | |
-r remote name | |
-h prints help | |
" | |
} | |
args="" | |
while [ $OPTIND -le $# ] | |
do | |
if getopts "r:h" option | |
then | |
case $option in | |
(r) remote=$OPTARG ;; | |
(h) usage | |
exit 0 ;; | |
(*) usage | head -n 1 | |
exit 2 ;; | |
esac | |
else | |
args="$args \"\${$OPTIND}\"" | |
OPTIND=$(($OPTIND + 1)) | |
fi | |
done | |
eval set -- "$args" | |
############################################################################# | |
count=${1:-10} | |
pattern=${remote:+refs/remotes/}${remote} | |
pattern=${pattern:-refs/heads/} | |
git for-each-ref --count=${count} --sort='-committerdate:iso8601' \ | |
--format="%(committerdate:iso8601) %(refname:short)" ${pattern} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment