git log shows the commit history with author, date, and message. git diff shows the exact line-by-line changes between different states of your files — working directory, staging area, or any two commits.
Git
Beginner
8 min read
git log and git diff
Example
# Compact one-line log:
git log --oneline
# Show last 5 commits:
git log -5
# Show commits by a specific author:
git log --author="Jane"
# Search commit messages:
git log --grep="authentication"
# Show commits that changed a specific file:
git log -- src/auth.js
# Pretty-formatted log with graph:
git log --oneline --graph --all --decorate
# ---- git diff ----
# Unstaged changes (working directory vs staging area):
git diff
# Staged changes (staging area vs last commit):
git diff --staged
git diff --cached # same as --staged
# Difference between two commits:
git diff abc123 def456
# Difference between two branches:
git diff main feature/login
# Difference for a specific file only:
git diff HEAD -- src/auth.js
# Show a summary (changed files + line counts):
git diff --stat