Git log Command
In this page:
Viewing Commit History
git log walks backward through your commit history, newest first, printing each commit's full hash, author, date, and message -- add --oneline to compress each entry to a single line when you just need a quick overview.
Example: Viewing Commit History
git log
git log --oneline
Limiting the Log Output
On a long-running project the full log can stretch for thousands of entries, so git log -n 5 (or any number) limits the output to just the most recent commits, which is usually all you actually need to check.
Example: Limiting the Log Output
git log -n 5
Filtering Logs by Author
On a team project, git log --author="name" filters the history down to commits from one specific person, which is useful for reviewing someone's recent work or tracking down who touched a particular area.
Example: Filtering Logs by Author
git log --author="Priya"
Filtering Logs by Date
git log --since="2 weeks ago" --until="yesterday" (or specific dates) filters commits to a date range, which is the fastest way to review exactly what changed during a sprint or before a release.
Example: Filtering Logs by Date
git log --since="2 weeks ago" --until="yesterday"
Visualizing History with Graphs
git log --graph --oneline --all draws an ASCII diagram of how your branches diverged and merged over time, turning an otherwise linear list into a visual map that makes complex branching history much easier to follow.
Example: Visualizing History with Graphs
git log --graph --oneline --all
Chapter Quiz — Complete all 18 topics to unlock
0/18 topics done
Complete these topics first:
- Git init Command
- Git New Files
- Git Staging Environment
- Git clone Command
- Git status Command
- Git help Command
- Git add Command
- Git commit Command
- Git tags Command
- Git stash Command
- Git log Command
- Git diff Command
- Git show Command
- Git rm Command
- Git mv Command
- Git restore Command
- Git clean Command
- Git ignore (.gitignore)