Practice: History Detective
Reading a project's past.
Let's practise reading history, like a detective. Here's a project with nine commits. You'll answer three questions, using only log, show, and diff. Pause after each question, and try it yourself first.

- A project with nine commits
- Three questions
- Use log, show and diff
Question one: how many commits?
Question one. How many commits does this project have, and what was the very first one? The short log answers both. Nine lines, so nine commits. And the bottom line, add home page, is the first.
git log --oneline b657d27 (HEAD -> main) Space out paragraphs 16670d6 Add contact note d70aa4a Expand about page 720bd51 Color the headings f63a17a Link to about page ef9c947 Add basic styles 6784119 Add about page 0ba6049 Add welcome text f7d9757 Add home page
Question two: who touched the styles?
Question two. Which commits changed the style file? Put the file name after git log. Three commits. Add basic styles, color the headings, and space out paragraphs.
git log --oneline style.css b657d27 (HEAD -> main) Space out paragraphs 720bd51 Color the headings ef9c947 Add basic styles
Question three: what changed?
Question three. What exactly did the commit called expand about page change? Find its hash in the log, then git show it. It added one line to the about page, I make websites.
git log --oneline -n 3 b657d27 (HEAD -> main) Space out paragraphs 16670d6 Add contact note d70aa4a Expand about page git show d70aa4a commit d70aa4ac87e3a2d93094bdf694e0537362470c47 Author: Sam Lee <sam@example.com> Date: Mon Jan 5 09:34:15 2026 +0000 Expand about page diff --git a/about.html b/about.html index 058b39b..1015a8f 100644 --- a/about.html +++ b/about.html @@ -1 +1,2 @@ <h1>About me</h1> +<p>I make websites.</p>
Summary
Log answers when, log with a file answers where, and show answers what. Next, comparing any two points in history.
Key takeaways- git log --oneline
- git log <file>
- git show <hash>