Git Log: Pretty Formats and Filtering

Master git log with pretty formats, graph visualization, and powerful filtering options. Find any commit in your repository history quickly.

git log --oneline --graph --decorate --all

Detailed Explanation

What Does git log Do?

git log displays the commit history of your repository. With the right flags, it becomes one of the most powerful investigative tools in Git.

Common Formats

# Compact one-line view with graph
git log --oneline --graph --decorate --all

# Custom format
git log --pretty=format:"%h %an %ar %s"

# Verbose with stats
git log --stat

Format Placeholders

Placeholder Meaning
%h Abbreviated commit hash
%H Full commit hash
%an Author name
%ae Author email
%ar Author date, relative
%s Subject (first line of message)
%b Body of commit message

Filtering Commits

# By author
git log --author="Jane"

# By date range
git log --after="2025-01-01" --before="2025-06-01"

# By file
git log -- src/components/Header.tsx

# By commit message keyword
git log --grep="fix login"

# Show changes introduced by each commit
git log -p

Graph Visualization

The --graph flag draws an ASCII art representation of the branch topology. Combined with --all, it shows every branch, not just the current one:

git log --oneline --graph --all

Aliases

Most developers create a shortcut for their preferred format:

git config --global alias.lg "log --oneline --graph --decorate --all"

Then simply run git lg. Understanding git log transforms how you navigate a project. It turns the commit history into a searchable, visual narrative of every change ever made.

Use Case

A developer needs to find all commits by a specific author that touched the authentication module in the last month to prepare a code review summary.

Try It — Git Command Builder

Open full tool