Appearance
Viewing History with git log
You made your first commit. Then another. Then a few more. Now you have a pile of commits and you need to see what happened, when, and by whom. git log is the tool for that.
This guide covers everything a beginner needs to read their project's history.
What git log shows
Run git log in any repository that has commits:
bash
git logOutput:
commit a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0 (HEAD -> main)
Author: Jane Doe <jane@example.com>
Date: Mon Nov 10 14:30:00 2026 -0500
Add payment retry logic
commit 9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c
Author: Jane Doe <jane@example.com>
Date: Mon Nov 10 12:00:00 2026 -0500
Initial commit: project scaffoldEach entry shows:
- Full commit SHA. The unique 40-character hash identifying the commit.
- Author. Who wrote it (configured via
git config user.nameanduser.email). - Date. When the commit was created.
- Message. The commit message. The first line is the subject. Blank line, then the body.
Newest commits appear first (reverse chronological order).
Compact view: --oneline
Full SHAs are verbose. For a quick scan:
bash
git log --onelinea1b2c3d (HEAD -> main) Add payment retry logic
9b8c7d6 Initial commit: project scaffoldThis shows the abbreviated SHA (7 characters) and the subject line. Use this 90% of the time.
See the branch structure: --graph and --all
When you have branches, git log --oneline --graph shows how they connect:
bash
git log --oneline --graph --all* a1b2c3d (HEAD -> main) Add payment retry logic
| * f5e6d7c (feature/search) Add search index
| * e4f5a6b Refactor search results
|/
* 9b8c7d6 Initial commit: project scaffoldEach * is a commit. The lines show parent relationships. |/ means a branch was merged or diverged. --all shows commits on every branch, not just the current one.
Filtering what you see
By number of commits
bash
git log --oneline -5 # last 5 commits
git log --oneline -1 # just the most recentBy author
bash
git log --author="Jane"
git log --oneline --author="jane@example.com"Matches any commit where the author name or email contains the string.
By date
bash
git log --oneline --since="2026-11-01"
git log --oneline --until="2026-11-10"
git log --oneline --after="2 weeks ago"--since and --after are the same. --until and --before are the same. Accept "2026-11-01", "2 weeks ago", "yesterday", "2026-11-01T12:00:00".
By commit message
bash
git log --oneline --grep="retry"
git log --oneline --grep="fix|bug" # regex: pipe means ORMatches commits whose message (subject + body) contains the pattern.
By file
bash
git log --oneline -- src/payments/Only shows commits that touched files in that directory or path.
Seeing what changed
Files changed
bash
git log --oneline --name-onlyAdds a list of changed files after each commit:
a1b2c3d Add payment retry logic
src/payments/retry.go
src/payments/retry_test.go
src/config/defaults.goStats per commit
bash
git log --oneline --statShows files changed, insertions, and deletions:
a1b2c3d Add payment retry logic
src/payments/retry.go | 45 ++++++++++++++++++++++++++
src/payments/retry_test.go | 30 ++++++++++++++++
src/config/defaults.go | 2 ++
3 files changed, 77 insertions(+)The actual diff
bash
git log -pShows the full patch (diff) for each commit. Use this sparingly. It is a lot of output. Pipe it through less or add -1 to see just one commit:
bash
git log -p -1What's happening here
| Command | What Git does | What you see |
|---|---|---|
git log | Walks the commit graph from HEAD backward | Full commit details |
git log --oneline | Same walk, abbreviated output | One line per commit |
git log --graph | Renders parent-child relationships | ASCII branch lines |
git log --grep= | Filters commits by message content | Matching commits only |
git log -- <path> | Filters commits touching a path | Matching commits only |
git log -p | Generates diff for each commit | Patch content |
git log --all | Walks every ref, not just current branch | All commits in repo |
Git does not store diffs. Each commit is a full snapshot. When you run git log -p, Git computes the diff by comparing the commit's tree with its parent's tree. That is why asking for patches is slower than listing commits.
Common mistakes
| Mistake | What happens | How to fix |
|---|---|---|
git log in a repo with no commits | Nothing prints. No error. | Make a commit first |
Forgetting --oneline in a big repo | Terminal fills with full SHAs | q quits the pager. Add --oneline next time |
git log --all when you meant just current branch | Shows extra commits from other branches | Omit --all to see only the current branch |
git log --grep=fix matches nothing | Empty output | Check spelling. Grep is case-sensitive by default; add -i for case-insensitive: --grep=fix -i |
git log -- src/ includes subdirectory matches | Correct behavior. File filtering is recursive | Use :(literal)src/ to match exactly or add a trailing slash |
Piping git log -p without limiting | Massive output, terminal scrollback lost | Add -5 or --since= to bound the range |
Combining filters
Filters stack. This shows commits from the last 7 days by Jane touching payment files, with stats:
bash
git log --oneline --stat --since="7 days ago" --author="Jane" -- src/payments/Order does not matter. All matching filters apply as an AND.
Quick reference
bash
git log # Full history
git log --oneline # One line per commit
git log --oneline -10 # Last 10 commits, compact
git log --oneline --graph --all # Branch topology
git log --author="Name" # Filter by author
git log --since="2 weeks ago" # Filter by date
git log --grep="fix" # Filter by message
git log --oneline -- src/ # Filter by path
git log --stat # Show file change stats
git log -p # Show full diffs
git log --oneline --graph --all --decorate # Everything, compactNext steps
Try git log --oneline --graph --all in a repo with multiple branches. The ASCII graph is the quickest way to understand your repo's topology. When you need to find a specific commit, combine --grep, --author, and --since instead of scrolling through hundreds of entries.