What is git log?

Answer

git log displays the commit history of the current branch, showing commits in reverse chronological order (newest first). Default output: commit hash, author, date, and message. Useful options: git log --oneline — compact single-line format (short hash + message); git log --graph — ASCII art graph of branch topology; git log --oneline --graph --all — visual history of all branches (very useful for understanding repo state); git log -5 — show last 5 commits; git log --author="Alice" — filter by author; git log --since="2024-01-01" --until="2024-06-01" — date range; git log --grep="bug fix" — search commit messages; git log -p / --patch — show diff for each commit; git log --stat — show changed files summary per commit; git log file.txt — history of a specific file; git log main..feature — commits in feature not yet in main. Format: git log --format="%h %an %s" — custom output (hash, author name, subject). git log is one of the most powerful and frequently used Git commands for understanding a project's history.