history
git log
Displays commit history in reverse chronological order with filters for author, date, path, or content. The primary tool for exploring project history.
git log [<options>] [<revision-range>] [<path>] Common flags
| Flag | Purpose |
|---|---|
| --oneline | Condense each commit to a single line |
| --graph | Draw an ASCII graph of branch/merge topology |
| -p | Show the patch (diff) introduced by each commit |
| --stat | Show per-file line change counts |
| --author=<pattern> | Filter by commit author |
| -S<string> | Pickaxe: find commits that add or remove <string> |
| --since=<date> | Only commits newer than the given date |
Examples
git log --oneline --graph --all Compact visual history across all branches
git log -p src/api.js Show every change to a single file with diffs
git log --since="2 weeks ago" --author="Alex" Recent commits by a specific author
Gotcha
'git log
Related commands
git diff
Shows line-level differences between commits, the index, and the working tree. Without arguments, compares unstaged changes to the index.
git reflog
Shows the log of updates to branch tips and HEAD stored locally, even after commits are dropped from history. The rescue rope for recovering 'lost' commits.
git status
Shows the state of the working tree and index: staged, unstaged, and untracked files, plus branch tracking info. The first command to run when you're unsure what changed.
git cherry-pick
Applies the changes from one or more specific commits onto the current branch as new commits. Useful for porting bug fixes across branches.
git tag
Marks specific commits with a permanent name, typically for release versions like v1.2.0. Supports lightweight tags (a ref) or annotated tags (a full object with metadata).