Lesson 06 of 10Concept

Staging Area

Goal: Understand why Git has a staging area between your files and your history.

A draft of your next commit

Git does not commit everything you changed. Instead, you choose which changes go into the next commit by placing them in the staging area (also called the index).

Think of it as a loading dock: you stage what is ready, then commit ships exactly what is on the dock.

Three places your work lives

Working Tree  ── git add ──▶  Staging Area  ── git commit ──▶  Repository
(your files)                  (next commit)                    (history)
git add copies a change into the staging area. git commit turns everything staged into a permanent snapshot.

Two changes, two focused commits

Step 1 of 5

Working Tree

  • login.jsModified
  • style.cssModified

Staging Area

Empty

Repository

  • login.js
  • style.css

You fixed a bug in login.js and, while you were there, restyled the page in style.css. Both are modified.

Step 1 of 5. You fixed a bug in `login.js` and, while you were there, restyled the page in `style.css`. Both are modified.

Why not commit everything at once?

Small, focused commits are easier to review, easier to understand months later, and easier to undo. The staging area is what lets you build them, even when your working tree holds several unrelated changes.

Finished reading?

Marking it complete records your progress and XP for this lesson.