# M02-L04 — Stage and commit a useful change

**Outcome:** Create a commit whose selected content and message explain one useful change.

**Start:** M02-L03 with the reviewed README edit still unstaged.

Staging selects content for the next commit. It is a snapshot at the time you add it; later working edits do not automatically join that selection. A commit records the staged snapshot with metadata and history relationships. [Pro Git recording changes](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository), [git commit](https://git-scm.com/docs/git-commit)

Confirm the CP01 baseline exists, the README edit is the intended one, and your repository-local identity uses your chosen name and actual GitHub no-reply address when desired. Commit identity is not remote authentication. Do not copy another learner's email or reveal a private address in a recording. [GitHub commit email](https://docs.github.com/en/account-and-profile/how-tos/email-preferences/setting-your-commit-email-address)

From the practice root, stage the exact file and inspect both comparisons:

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

The intended label edit moves to the cached comparison. Read it before committing. If you edit README again, the working and staged versions may differ; inspect both and stage the later change only if it belongs in the same commit.

Commit with a purpose-focused message, then inspect the two-entry history:

```powershell
git commit -m 'Clarify synthetic input in the report label'
git log --oneline -2
git status
```

Your commit identifier will differ from the instructor's because metadata contributes to it. Assess the content and message, not exact hash equality with a screenshot. A clean final state confirms repository agreement; keep any software verification result separate.

![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-01; SS05-04–05; D05. 
