Published on April 21, 2012 by Andrei Petre
Tagged: git, .gitconfig, alias, speed, log, config

If you didn’t read the techblog Git Tips and Good Practices article yet, you should, as it offers tips every git user should know, together with some very useful references.

When using git for the first time, one has to specify his name and email, so git can associate the commit with who committed it:

$ git config --global "Firstname Lastname"
$ git config --global ""

This adds info to ~/.gitconfig, a global configuration file git uses. Also, every git project has its own .git/config file (similar to the global one), and any options from this file overwrites the options from the global file.

andrei@sherlock:~$ cat ~/.gitconfig
    name = Andrei Petre		# filled by the
    email =	# above commands
    ui = auto
    pager = true
    editor = vim
    user = andreip
    token = ...
    co = checkout
    ci = commit
    st = status
    br = branch
    df = diff
    pa = add --patch
    rlog = reflog			# useful for lost SHA's
    type = cat-file -t
    dump = cat-file -p
    hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
    lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset 
         %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

Most of these configurations are self explanatory. The part that I find it most useful and what this article was all about (but needed an intro) are the last two aliases.

  • git hist (from gitimmersion) is a short version of git log

git lg

  • git lg (from Andrei Maxim) is also a short and pretty formatting version of git log

git lg

Use the one you like best, and add speed to your workflow.

comments powered by Disqus