This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Git Log Cheatsheet

A quick reference guide for git log: revision range filtering, pickaxe code searches, history simplification, date filters, graph views, and pretty formats.

· Published

git-log shows commit logs, visual graphs, and code evolution across branches and tags.

Revision Ranges

git log master             # Branch tip
git log origin/master      # Remote tracking branch
git log v1.0.0             # Specific tag release

git log master develop     # Commits in either master or develop

git log v2.0..master       # Reachable from master but NOT from v2.0
git log v2.0...master      # Symmetric difference: reachable from either, but not both

See: Git Revisions Cheatsheet

Basic Filters

-n, --max-count=5          # Limit to 5 commits
--skip=2                   # Skip first 2 commits
--since="2 weeks ago"      # Commits newer than date
--until="yesterday"        # Commits older than date
--author="Alice"           # Filter commits by author string
--committer="Bob"          # Filter commits by committer string
--grep="fix: auth"         # Search commit messages

Search Flags (Pickaxe & Regex)

-S"functionName"           # Pickaxe: find commits that added or removed the exact string
-G"regexPattern"           # Find commits where diff match regex pattern
-L :main:app.c             # Trace the evolution of function 'main' in app.c
-L 15,30:app.c             # Trace the evolution of line range 15-30

History Simplification

--first-parent             # Follow only first parent commit on merge commits
--no-merges                # Omit merge commits
--merges                   # Show only merge commits

Ordering

--date-order               # Show commits in strict timestamp order
--topo-order               # Show parent commits before child commits
--reverse                  # Output commits in chronological order (oldest first)

Formatting Options

--oneline                  # Short hash and subject line
--stat                     # Diffstat showing files changed and lines added/deleted
--shortstat                # Summary numbers of changed files
--graph                    # Draw ASCII visual branching graph
--patch, -p                # Display full unified diff patch

Custom Pretty Formatting

git log --pretty=format:"%Cred%h%Creset - %C(yellow)%an%Creset : %s (%cr)"

See: Git Log Format Placeholders Cheatsheet

References

Related topics