Log & History in Git

From the Git cheat sheet · Viewing History · verified Jul 2026

Log & History

Explore repository history and find specific commits

bash
# View log
git log
git log --oneline
git log --graph --all
git log -n 5           # Last 5 commits

# Search commits
git log --grep="keyword"
git log --author="name"
git log --since="2 weeks ago"

# File history
git log -- <file>
git log -p <file>      # With changes
git blame <file>       # Line-by-line authorship
💡 Use --graph for visual branch history
⚡ Combine flags for powerful searches
📌 Blame shows who changed each line
✅ Use shortlog for contribution summary
Back to the full Git cheat sheet