Skip to Content

Git: Pretty Log Printing

Git commands have many, many options for controlling what they do, and the command git log is no different.

One StackOverflow:pretty-git-logs thread has some suggested commands that create nice-looking textual graphs of git logs, and show the power of the commands.

One example is:

git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(green)(%ar)%C(reset) %C(black)%s%C(reset) %C(dim white)- %an%C(reset)%C(red)%d%C(reset)' --all

What does all that mean? I leave it to you to investigate, but you can run the command on your own repository and get an idea by looking at the output.

Use Your GitConfig for Complex Commands

You can create aliases in your local .gitconfig file that captures this and any complex git command that you want to use a lot. For example, you can have this in your .gitconfig:

      plog = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(green)(%ar)%C(reset) %C(black)%s%C(reset) %C(dim white)- %an%C(reset)%C(red)%d%C(reset)' --all

Then you can use the command git plog and this will do a log command with all of the options listed.

Other Resources

Just google pretty git logs or something like that and you can find lots of possibilities. Even python scripts and other tools to convert the textual output into actual graphs!