# M02-L03 — Read your first Git diff

**Outcome:** Explain the exact changed lines before staging or committing them.

**Start:** M02-L02; CP01 source-only practice folder and its baseline commit.

A diff compares versions. In this lesson, ordinary `git diff` compares working changes against staging. The cached view compares the staged snapshot against the current commit. A minus line shows previous content; a plus line shows new content. Those markers belong to the display, not the source file. [git diff](https://git-scm.com/docs/git-diff)

Prepare the Chapter 5 baseline in a separate CP01 source-only folder. From its root in PowerShell, run the sequence below, replacing the two identity values with your chosen name and actual verified no-reply address. Inspect each result before the next operation:

```powershell
Get-Location
git init -b main
git config user.name 'Your chosen author name'
git config user.email 'YOUR-VERIFIED-NOREPLY-ADDRESS'
git status
git add README.md .gitignore dependencies.json firmware host scripts fixtures docs CHECKPOINT.md
git diff --cached
git commit -m 'Record sensor monitor baseline and build instructions'
git status
```

Review the selected source and run the applicable CP01 replay/build from M02-L02 before the baseline commit. If the bundle already contains history, stop and select the source-only CP01 extraction instead. A clean status is a repository-state observation, not a test result.

The actual CP01 README contains `Report label: synthetic.` Change only that line to `Report label: synthetic input.` in VS Code and save. This clarifies the human-facing label without changing firmware behavior or a machine-readable output format. Inspect Source Control and run:

```powershell
git status
git diff -- README.md
git diff --cached
```

Before staging, the README edit should appear in the ordinary diff and the cached comparison should contain no new change. Read the file header, removed line, added line, and surrounding context. Explain the purpose and what remains unchanged because you inspected it.

If the whole file appears replaced, investigate line endings or formatting before accepting it as a one-line task. If another file changed, compare it against the brief. Do not judge a diff by its green color or by an assistant saying it is small; identify the actual behavior each hunk changes.

![Saving changes the working tree; add selects contents in staging; commit records that selected snapshot. Ordinary and cached diffs compare different states.](../../../../book/figures/D05.png)

*D05. Saving changes the working tree; add selects contents in staging; commit records that selected snapshot. Ordinary and cached diffs compare different states.*

## Practice and completion

Complete the [exercise](exercise.md), then compare your artifact with the separately distributed instructor answer. A lesson acknowledgment records your own progress; it does not certify that a physical test occurred.

## Reading and figures

[Chapter 5](../../../../book/chapters/ch05/chapter.md). Resources: [Project checkpoint guide](../../../../examples/sensor-monitor/docs/checkpoints.md) and [toolchain setup](../../../../examples/sensor-monitor/docs/setup.md). Figure references: SS05-02–03; D05. 
