Skip to content

Instantly share code, notes, and snippets.

@dragonly
Last active June 18, 2021 02:04
Show Gist options
  • Save dragonly/4bb11a456f91ed66f004655720193b60 to your computer and use it in GitHub Desktop.
Save dragonly/4bb11a456f91ed66f004655720193b60 to your computer and use it in GitHub Desktop.
git log visualization
# put this in your ~/.gitconfig, then issue `git lg` will get you a pretty git branch topology view
#
# this is just a start point, customizations can be done by further fine tuning referencing
# https://git-scm.com/docs/git-log & https://git-scm.com/docs/pretty-formats
#
# --graph draws the git commits tree
# --date=local is used in the following --format
#
# format explanation:
# %C(colorname)xxx%C(reset) encloses text `xxx` with color `colorname`
# %h shows abbreviated commit hash which is short and enough for copy and paste in other git commands
# %ad will use date format according to --date value, which is `local`, because I don't like the verbose ISO or RFC2822 style date
# %ar shows relative date from now
# %s shows the commit log
# %an shows the author name
# %d shows the ref names if any, like `(HEAD -> master, origin/master)`, and %C(auto) will make it colorful
[alias]
lg = log --all --graph --date=local --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%ad%C(reset) \
%C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment