Git aliases


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 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"

Another example to do by-character diffs:

git config --global alias.dw "diff --color-words='[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+'"