LLearnCode
Academy/git/Make reviewable changes

intermediate · 25 minute study

The commit records the index, not everything in your editor

Create focused commits without accidentally publishing unfinished edits or assuming that saved files are already part of a commit.

Loading progressEvidence grows with practice
Useful preparation · 1 prerequisite

Use this as a map, not a lock. If these ideas are familiar, continue.

First, build a mental model

Keep three snapshots separate: the working tree is what you are editing, the index is what the next ordinary commit will record, and HEAD identifies the current committed history position.

  1. Editing a tracked file changes the working tree, not the existing commit.
  2. git add copies the selected current file content into the index. Later edits are not automatically restaged.
  3. git diff compares working tree to index; git diff --staged compares index to HEAD.
  4. An ordinary git commit records the index. Inspect that exact staged diff, including added files, before committing.
  5. Untracked and ignored files have separate status. Review scope and exclusions rather than assuming a broad git add is always appropriate.
Read the codeshell · educational example
# In a disposable learning repository:
# 1. HEAD contains src/score.js version A.
# 2. Edit it to version B.
git add src/score.js
# 3. Edit the same file again to version C.
git diff -- src/score.js
git diff --staged -- src/score.js
# An ordinary commit now records version B, not C.
  1. HEAD

    The committed file remains version A.

  2. Index

    Staging captured version B when git add ran.

  3. Working tree

    The later edit is version C. Its difference from B is still unstaged.

Production thinking

Take this beyond the example.

Keep unrelated work out of a change, inspect new files for private material and pair each validation claim with the tested snapshot. Staging is a review boundary, not merely a command to memorize.

Sources and further reading

Your evidence

unseen is a local learning signal, not a credential or proof of production competence.

Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.

Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.

Next lesson · Branches are names that move through a graph →