Git Alias for One-Line Log with Graph

Create a git alias that displays a compact one-line log with branch graph. Shows commit history visually with abbreviated hashes and decorations.

Log Aliases

Detailed Explanation

Compact Log with Branch Graph

One of the most popular git aliases replaces the verbose default git log output with a condensed, visually rich alternative. The alias lg maps to:

git log --oneline --graph --decorate

What Each Flag Does

Flag Purpose
--oneline Shows each commit on a single line with abbreviated hash and subject
--graph Draws an ASCII branch topology graph in the left margin
--decorate Annotates commits with branch names, tags, and HEAD position

.gitconfig Entry

[alias]
    lg = log --oneline --graph --decorate

Extending the Alias

Many developers extend this further to include all branches:

[alias]
    lol = log --oneline --graph --decorate --all

The --all flag includes commits from every branch and tag, not just the current branch. This gives you a helicopter view of your entire repository history.

Adding Color

For even richer output, you can use a custom --format string:

[alias]
    graph = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'

This produces color-coded output showing the hash in blue, relative date in green, subject in white, and author name in dim white. Branch decorations use git's automatic coloring.

Use Case

Use this alias every day to quickly review recent commits, understand branch topology, and see where feature branches diverged from the main branch. It is especially helpful during code reviews and when deciding where to rebase or merge.

Try It — Git Alias Builder

Open full tool