bashintermediate

Git Log — Search, Filter, and Visualize

Advanced git log techniques for searching commit messages, filtering by author/date, and visualizing.

bash
# Search commit messages
git log --grep="fix" --oneline

# Search by author
git log --author="Jane" --oneline --since="2024-01-01"

# Search code changes (pickaxe: find when string was added/removed)
git log -S "functionName" --oneline

# Search with regex in code
git log -G "TODO|FIXME|HACK" --oneline

# Graph visualization
git log --graph --oneline --all --decorate

# Custom format
git log --pretty=format:'%C(yellow)%h%Creset %C(blue)%ad%Creset %C(green)%an%Creset %s' \
  --date=short -20

# Show files changed per commit
git log --stat --oneline -10

# Commits touching a specific file
git log --oneline --follow -- src/auth.ts

# Commits between two tags/branches
git log v1.0..v2.0 --oneline

# Commits in branch-A but not in main
git log main..feature/auth --oneline

# Shortlog (summary by author)
git shortlog -sn --since="2024-01-01"

# First parent only (skip merge internals)
git log --first-parent --oneline main

# Show merge commits only
git log --merges --oneline -10

Use Cases

  • Searching project history for specific changes
  • Generating changelogs and release notes
  • Auditing who changed what and when

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.