Nicer git log

Another really nice addition to to git aliases – git log is particularly ugly. This one I found here

Basically turn this:

AwZKW

into this:

tSgaU

Using:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Or as an alias in your ~/.bashrc ~/.zshrc:

alias gitlg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

Show all git branches, ordered by date

By default, “git branch -a” shows you both local and remote branches for your repository. Wondering when each branch was worked on last? It’s a bit hard, especially that git makes 2 piles of branches – the local ones and the remote ones separately. To see them ordered by when they were worked on last, just use :

   for k in `git branch -a|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r

If you’re like me and use this a lot, make it a function and add it as an alias to your .bashrc/.zshrc/.whateverrc

function gitbr {
   for k in `git branch -a|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r
}
alias gitbr=gitbr