Reading history
Beginner Git CLI VS Code UI IntelliJ UI GitLab UI GitHub UI
Why this matters
History is the reason version control exists, and reading it is a skill non-developers use more than developers: "when did this sentence change?", "who decided the default was 10?", "what went into the last release?". Three commands answer everything; the flags are the vocabulary.
git log: the list
The default output is long. Start with one line per commit:
$ git log --oneline -5c541c80 docs: add maintainer note
79c86c5 feat: add Eagle Ridge trail (#21)
dcc61f1 docs: describe the region and answer a data question (#28)
8e4a443 chore: add todo
a32e63b docs: remove tmpNewest first; -5 limits the count. Add labels and a graph of branches:
$ git log --oneline --graph --decorate -4* c541c80 (HEAD -> main) docs: add maintainer note
* 79c86c5 feat: add Eagle Ridge trail (#21)
* dcc61f1 docs: describe the region and answer a data question (#28)
* 8e4a443 chore: add todoThe * column draws the chain; with branches and merges it forks and joins. --all includes every branch, not just the current one. (The starter configuration's git lg alias is exactly this.)
Filtering
| Question | Command |
|---|---|
| History of one file | git log --oneline -- docs/faq.md |
| …following renames | git log --oneline --follow -- docs/faq.md |
| Commits by one person | git log --oneline --author=Ana |
| Since a date | git log --oneline --since="2026-09-03" (also --until, --since="2 weeks ago") |
| Messages containing a word | git log --oneline --grep="#21" |
| Commits that changed a given text | git log --oneline -S "public domain" |
| Files touched per commit | git log --stat --oneline -2 |
| Between two points | git log --oneline v1.2.0..main (what main has that the tag does not) |
$ git log --oneline -- docs/faq.mddcc61f1 docs: describe the region and answer a data question (#28)
2f543f1 docs: explain how to add a trail (#27)
0d9eb38 docs: add map question to FAQ (#9)
8fa922e Initial import of trailguide$ git log --stat -2 --onelinec541c80 docs: add maintainer note
README.md | 2 ++
1 file changed, 2 insertions(+)
79c86c5 feat: add Eagle Ridge trail (#21)
data/trails.csv | 1 +
1 file changed, 1 insertion(+)A custom one-liner with dates is handy for reports:
$ git log --pretty=format:"%h %ad %an %s" --date=short -4c541c80 2026-09-07 Ana docs: add maintainer note
79c86c5 2026-09-07 Ana feat: add Eagle Ridge trail (#21)
dcc61f1 2026-09-07 Ana docs: describe the region and answer a data question (#28)
8e4a443 2026-09-09 Ana chore: add todogit show: one commit, or one file at a time
$ git show HEAD --statcommit c541c807612e2b322396e0defbaa843bdc7a0a27
Author: Ana <ana@northwind-trails.example>
Date: Mon Sep 7 09:30:00 2026 +0200
docs: add maintainer note
README.md | 2 ++
1 file changed, 2 insertions(+)Without --stat, the full diff follows the message. git show <hash> works for any commit; git show v1.2.0 for a tag. A different use, easy to miss: a file as it was at a commit, printed without touching your working tree:
$ git show HEAD~2:data/trails.csvname,region,distance_km,difficulty
Ridge Loop,North,7.5,moderate
…
Twin Falls Track,South,8.8,moderate<commit>:<path> is the syntax. Redirect it to a file (git show HEAD~2:data/trails.csv > old-trails.csv) to compare versions in a spreadsheet, or read it to answer "what did the guide say at release 1.2?".
git blame: who last touched each line
$ git blame -L 1,5 docs/faq.md --date=short^8fa922e (Ana 2026-09-01 1) # Frequently asked questions
^8fa922e (Ana 2026-09-01 2)
^8fa922e (Ana 2026-09-01 3) ## Is Trailguide free?
^8fa922e (Ana 2026-09-01 4)
^8fa922e (Ana 2026-09-01 5) Yes. It is a practice project for the Git Course and can be used, changed and shared freely.Each line: the commit that last changed it (^ marks the initial commit), the author, the date, the line number, the line. -L 1,5 limits to lines 1–5. Blame answers "which commit put this here?"; then git show <hash> answers why. Two cautions: blame shows the last change, which may be a reformatting rather than the author of the idea (-w ignores whitespace changes, -M follows moved lines); and the name is a starting point for a question, not for an accusation. Many teams say "annotate" for that reason.
In the tools
Everything above. Long output opens the pager: Space forward, b back, /word to search, q to quit. --no-pager before log prints straight to the screen.
- Source Control Graph (a section of the Source Control view): the branch graph with messages; click a commit to see its files and open any as a diff. This is
git log --graph. - Timeline (bottom of the Explorer, with a file open): that file's history,
git log -- <file>; click an entry for the diff. - Blame: with the GitLens extension, the current line's last commit appears inline at the end of the line, and File Annotations (the GitLens toolbar icon) show blame for every line. Without GitLens, right-click → Open Timeline is the nearest thing.
- Command Palette → Git: View File History requires GitLens or the Git History extension.
- Git tool window → Log tab (Alt+9 / ⌘9): the full graph, with filters for branch, user, date and text at the top, and the commit's files on the right. Double-click a file for its diff at that commit.
- Right-click a file → Git → Show History for one file's log (follows renames).
- Right-click the editor's gutter → Annotate with Git Blame: author and date beside every line; click a line to open the commit. The gear menu offers Ignore Whitespaces and Detect Movements.
- Right-click a commit in the Log → Show Diff / Compare with Local for
git showandgit diff.
Code → Commits is the log (filter by branch, author and message search). In the file view: History for git log -- <file>, Blame for git blame with clickable commits and a slider to blame older versions, Permalink for the file at this exact commit (git show <commit>:<path>). Code → Compare revisions is git log a..b with diffs.
Commits (the clock icon on the repository page) is the log; a file's History and Blame buttons are git log -- <file> and git blame, with a "view blame prior to this change" arrow that walks back through rewrites. Press y on a file page to get a permalink to that commit's version.
Common mistakes
- Scrolling through the default
git loglooking for something. Use--onelineand a filter. - Blaming a line and stopping there. The last change may be a rename or whitespace fix; use
-w, and check the file's history for the real origin. - Forgetting
--before a file name when a branch has the same name. - Looking for uncommitted work in the log. The log has commits only;
git statusandgit diffhave the rest.
Try it yourself
Goal: trace one line of the playground FAQ to its commit.
- Run
git blame docs/faq.md --date=shortand pick any line's hash. - Run
git show <hash> --statfor that hash. - Run
git log --oneline -- docs/faq.mdand find the same hash in the list. - Run
git show <hash>:docs/faq.md | head -5to read the file as it was at that commit.
Expected result: the blame hash appears in the file's log; git show gives its message, author, date and files; the <hash>:<path> form prints the old content.
Show solution
Blame → show → log is the standard chain: find the commit, read its story, see it in context. In a fresh playground every line points at your import commit; after the earlier exercises, lines you added point at your later commits.