0%

Reading History

Find When the Price Broke

The current stock.csv says a fig tree costs 38.00. The history says that a customer once saw a price of 3800. The price is fixed now, but you want to answer a better question: when did it first become wrong?

This is where reading history stops being sightseeing and becomes an investigation.

Narrow the history to the relevant file

Plain git log shows all eleven . You already know how to read it, but most of those commits cannot answer a question about stock.csv.

Add a path after -- to ask for only commits that changed that file:

git log -- stock.csv

The -- is a separator. It tells Git that everything after it is a file path, not a commit identifier or an option. stock.csv then limits the result to commits that changed that path.

Three commits remain, newest first:

  1. Fix the fig price, which had lost its decimal point

  2. tidy up stock formatting

  3. Add the stock list

The first message tells you when the problem was fixed. It does not prove when the problem began. For that, inspect the earlier candidate.

Open the suspicious commit

The vague message tidy up stock formatting belongs to commit 2cce597. Use the plain git show form you already know:

git show 2cce597

The last two changed lines are the answer:

-fig,38.00,3
+fig,3800,3

The older snapshot had 38.00. This commit’s snapshot has 3800. The price first became wrong in 2cce597, on March 6, under a message that did not hint at the damage.

Verify instead of guessing from messages

You found the change with three small moves:

  1. Start with git log to understand the shape of the history.

  2. Narrow it to the relevant file with git log -- stock.csv.

  3. Use git show to check a candidate’s changed lines.

git diff is available whenever the question names two states rather than one candidate commit. The important habit is the same: use messages to choose where to look, then use the diff as evidence.

Which evidence proves that commit 2cce597 introduced the broken fig price?

You can now walk into an unfamiliar without treating its history as a wall of code. Read the signposts, open one commit, compare states, and keep narrowing until the changed lines answer your question. The next chapter uses that calm reading habit before asking you to undo anything.