When you checked your changes with git diff, every question you asked Git was about the present, such as what you changed and what you staged. The README’s to-do list now raises a question about the past. Its first item says that eggs go back to $4.99 a dozen starting on Wednesday, November 25. Before you change a price, it helps to know when it last changed and why. Maybe someone marked it down on purpose, a week ago or a day ago.
In this lesson, you’ll answer that question from the store’s history instead of from anyone’s memory. You’ll list the commits that touched one file, show what a single commit changed, narrow the list by author and by date, and compare two commits with each other. Start with the list of every commit the project has.
Find the Commits That Changed a File
In the generic-grocery folder, run the command you already know:
$ git log --oneline
2156199 (HEAD -> main) Mark down the cranberries for the rest of the week
10c2002 Add .gitignore to the README's file table
cb4f95a Update the phone number in the footer
ac7b50d Remove the hand-made copies of the deals
398aecf Add the store's site as it arrived
Your hashes will differ from the examples throughout this lesson. None of the five subjects mentions eggs. That’s a good sign, but a subject only summarizes a commit. In the last lesson, you saw how a single stray keystroke can turn 399 into 3999, and a subject wouldn’t tell you about that.
What you want to know is which commits changed src/data/deals.js, the file where the egg price lives. You can give git log a path, and it lists only the commits that changed that file:
$ git log --oneline -- src/data/deals.js
2156199 (HEAD -> main) Mark down the cranberries for the rest of the week
398aecf Add the store's site as it arrived
Out of five commits, two touched deals.js. The first commit counts, because it added the file to the repository, and your cranberry markdown is the only change since then. The other three commits changed the footers, the README, and the two handmade copies, so the path leaves them out.
The -- before the path tells Git that everything after it is a filename, not the name of a commit. Git can often work this out without it, but the -- makes your intent clear, and it’s the form you’ll see in most documentation.
The one-line view hides the dates. Leave out --oneline to see each commit’s author, date, and full message:
$ git log -- src/data/deals.js
commit 2156199051eca0e467da269744f64ef7079ae3c7 (HEAD -> main)
Author: Martin Breuss <[email protected]>
Date: Fri Nov 20 14:36:20 2026 -0500
Mark down the cranberries for the rest of the week
More bags are left than expected, so the sale price drops
until the deal week ends.
commit 398aecf9248680a87684635eb1952aaae8eea7a1
Author: Martin Breuss <[email protected]>
Date: Fri Nov 20 13:12:08 2026 -0500
Add the store's site as it arrived