bashbeginner
Git Log Formatting Tricks
Custom git log formats with graphs, filtering by author, date ranges, and file changes.
bashPress ⌘/Ctrl + Shift + C to copy
# One-line log with graph
git log --oneline --graph --all --decorate
# Custom pretty format
git log --pretty=format:'%C(yellow)%h%Creset %C(green)%ad%Creset | %s %C(red)%d%Creset [%an]' --date=short
# Show only last N commits
git log -10
# Filter by author
git log --author="Alice" --oneline
# Filter by date range
git log --after="2024-01-01" --before="2024-06-30" --oneline
# Show commits that changed a specific file
git log --follow -- src/lib/registry.ts
# Show diff for each commit
git log -p -3 # last 3 commits with full diff
# Show stat summary
git log --stat --oneline -5
# Search commit messages
git log --grep="fix" --oneline
# Search code changes (pickaxe)
git log -S "functionName" --oneline
# Show merge commits only
git log --merges --oneline
# Show commits NOT yet merged to main
git log main..feature-branch --oneline
# Save a git log alias
git config --global alias.lg "log --oneline --graph --all --decorate"Use Cases
- Reviewing project history efficiently
- Finding when a specific change was introduced
- Generating changelogs and release notes
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashintermediate
Git Log — Search, Filter, and Visualize
Advanced git log techniques for searching commit messages, filtering by author/date, and visualizing.
Best for: Searching project history for specific changes
#git#log
bashintermediate
Squash Multiple Git Commits
Interactive rebase to squash multiple commits into one clean commit before merging a feature branch.
Best for: Cleaning up messy commit history
#git#squash
bashadvanced
Git Interactive Rebase Guide
Interactive rebase to reorder, edit, drop, and squash commits for a clean Git history.
Best for: Crafting a clean commit history before merge
#git#rebase
bashintermediate
Git Blame Investigation Techniques
Use git blame and related tools to trace code authorship and understand change history.
Best for: Finding who introduced a bug
#git#blame