Git
Git Log CLI
Git log commands for history exploration and filtering.
31 commands
Windows
MacOS
Linux
#history
#version-control
Basic Log
Show full commit history
git log
Show last 10 commits
git log -n 10
Show commits as single lines
git log --oneline
Show commits from all branches
git log --all
Follow file history through renames
git log --follow -- path/to/file
Formatting
Custom format with hash, author, subject
git log --pretty=format:"%h %an %s"
git log --pretty=format:"%H %ad %s" --date=short # Full hash with short date
Show branch and tag names
git log --oneline --decorate
Colored output format
git log --format="%Cgreen%h%Creset %s"
Show abbreviated commit hashes
git log --abbrev-commit
Filtering
Filter commits by author name
git log --author="John"
Show commits after a date
git log --since="2024-01-01"
Show commits before a date
git log --until="2024-06-30"
Search commit messages for pattern
git log --grep="fix"
Show commits affecting a file
git log -- path/to/file
Show commits in feature not in main
git log main..feature
Graph & Statistics
Show branch graph with all branches
git log --graph --oneline --all
git log --graph --decorate --abbrev-commit # Graph with decorations
Show file change statistics
git log --stat
Show summary of changes per commit
git log --shortstat
Show numeric diffstat per commit
git log --numstat
Count commits per author
git shortlog -sn
Searching
Find commits that add or remove string
git log -S "functionName"
Find commits matching regex in diff
git log -G "regex_pattern"
Search across all remote branches
git log --all --source --remotes
Find commits that deleted JS files
git log --diff-filter=D -- "*.js"
Show only merge commits
git log --merges
Exclude merge commits
git log --no-merges
Quick Commands
Show branch graph with all commits on one line
git log --oneline --graph --all
Find commits that add or remove a string
git log -S "functionName"
Filter commits by author and date
git log --author="John" --since="2024-01-01"