How to do it...

Here, we'll see some examples of aliases, with a short description of each of them and an example of how to use them. The aliases are just made for the local repository; use --global to make them available for all the repositories.

  1. Let's begin with an alias to show the current branch only:
$ git config alias.b "rev-parse --abbrev-ref HEAD"
$ git b
aliases
  1. To show a compact graph history view with colors, the following alias will save you many keystrokes:
$ git config alias.graph "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
$ git graph origin/conflict aliases

The following screenshot shows you a typical output, where commits ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.