Skip to content

Instantly share code, notes, and snippets.

@baseonmars
Last active January 4, 2016 16:59
Show Gist options
  • Save baseonmars/8650836 to your computer and use it in GitHub Desktop.
Save baseonmars/8650836 to your computer and use it in GitHub Desktop.
List git branches in order of age
#!/bin/bash
location="--list"
while getopts rla opt; do
case $opt in
r)
location="--remote"
;;
l)
location="--list"
;;
a) location="--all"
;;
esac
done
echo $r
for k in `git branch $location|grep -v -e "HEAD ->"|sed s/^..//`;do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k" `\\t"$k";done|sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment