for k in `git branch | sed s/^..//`; do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"`\\t"$k"; done | sort
To reverse the order add -r
switch at the end.
ref: http://stackoverflow.com/questions/9236219/git-list-git-branches-sort-by-and-show-date
Put this command in git alias (~/.gitconfig):
[alias]
bs = "!f() { for k in $(git branch | sed s/^..//); do echo $(git log -1 --pretty=format:'%Cblue%ci %Cgreen%cr%Creset' ${k})\t${k}; done;}; f | sort ${1}"
bsr = "!f() { for k in $(git branch -r | sed s/^..//); do echo $(git log -1 --pretty=format:'%Cblue%ci %Cgreen%cr%Creset' ${k})\t${k}; done;}; f | sort ${1}"
Usage:
List local branches
$ git bs
List remote branches
$ git bsr
Other aliases: http://ubuntunurd.blogspot.com/2013/02/git-config.html
SWEET! Thanks a bunch man. Saved me tons of time.
ReplyDeleteHi Tom,
ReplyDeleteYou are welcome!
I give credit to Ondra @ http://stackoverflow.com/questions/9236219/git-list-git-branches-sort-by-and-show-date
Recently I put that command into git alias.