Git aliases

Basics

Git aliases allow to define a short, easy to remember alias for a possibly complicated git command.

The basic syntax works like this:


git config --global alias.aliasname "command"

This defines a new alias in global mode, which means that it will be available for all repositories of the currently logged in user. Below are some aliases which I like.


Better log

The following alias from http://www.jukie.net/bart/blog/pimping-out-git-log displays a nicely formatted, easily readable log output.


git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)

an>%Creset' --abbrev-commit --date=relative"
</code>
 
Another example to do by-character diffs:
 
<code>
git config --global alias.dw "diff --color-words='[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+'"
</code>