git log
Walk the chain of parent links and read your history.
What it does
git log is a pure read operation: starting from HEAD, it follows each commit's parent pointer to the previous commit, forever. Every commit object is rendered as a line (or more) of metadata and its message. None of it touches your working tree.
A light beam sweeps down the parent pointers, printing each commit
Watch it — press play
A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.
Step 1
Ask who did what
git log starts at HEAD and follows every parent pointer, printing each commit.
git log --oneline --graphThe newest commit is on top
Under the hood
It's a linked-list traversal
Commits only know their parents. Log starts at a ref (say HEAD), prints it, jumps to parent, prints it, and continues. Merchant/rendering aside, that IS the algorithm.
HEAD → 74d3b9f → parent → 4b7c2a5 → parent → 9a2f1c0 → <no parent>
--oneline formats one commit as one hash + subject
The short 7-character hashes come straight from the first 7 hex digits of the full 40-digit object hash. Two commits could theoretically collide in 7 digits — Git shows the abbreviated prefix only.
--graph draws the DAG
Merges make the commit list a graph, not a line. --graph tracks which 'lane' each commit belongs to and draws the branch topology with ASCII (or, with --color, painted) box-drawing characters.
Range and filter syntax
`git log main..feature` means 'commits reachable from feature but not from main' — read it as a set-difference over the DAG. `git log -p` appends the full diff of each commit.
Aliases the pros type
Memorize the git log concept, then let one of these shortcuts make it instant. Aliases are real git config keys — add one with:
git config --global alias.st # → git log --oneline --graphg lggit log --oneline --graphThe one-liner history view everyone pastes into their config.
g lgggit log --all --graph --oneline --decorateEvery branch, fully drawn, with ref names.
g lgpgit log --oneline --statCompact log with per-commit file stats.
g lsgit log --stat -pDeep dive: what each commit did to each file.
Command anatomy
--onelineEach commit on one line: 7-char hash + subject.
--graphPaint the branch topology with ASCII lanes.
-pShow the full diff of every listed commit.
-n <count>Limit output to the newest n commits.
--author=Filter commits by author pattern.
-S"string"Only commits where that string was added or removed.
When to reach for it
Answering 'what changed and when' — the daily archaeology of git.
Reviewing your own work before opening a PR: git log --oneline -10.
Finding when a bug appeared: git log -S"buggyExpr" -- file.
Pro tip
Add a lazy alias you'll use forever: `git config --global alias.tree "log --graph --oneline --all --decorate"`. Then `git tree` gives you the whole universe in one screen.