Git
View Commit History with git log
Browse, filter, and format commit history with git log options.
By EZ4Code Team
loghistorybeginner
Code
# Compact one-line history
git log --oneline
git log --oneline -10 # last 10 commits
# Show changes (patch) for each commit
git log -p -2
# Show file stats per commit
git log --stat
# Search commit messages
git log --grep="fix"
git log --author="Alice"
# Show commits that touched a file
git log -- file.txt
git log --follow -- file.txt # follow renames
# Visual graph of branches
git log --oneline --graph --all --decorate
# Commits between dates
git log --since="2 weeks ago" --until="yesterday"
# Format output
git log --pretty=format:"%h %an %ar %s"Explanation
Filters and formats commit history: --oneline for compact view, -p for patches, --stat for file stats, and --grep/--author for searching. --follow tracks a file through renames, and --graph visualizes branch structure. --since/--until and --pretty=format enable date-range and custom-format output.