GIT / A CONCEPT NOTE
The Staging Area
why git has three states
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
The staging area (index) acts as a middle zone between your working directory (active files) and your commit history (snapshots), letting you select exactly what changes to commit.
02 / FOLLOW THE MECHANISM
How files move through states
Modify file
changes files in working directory (untracked/modified status).
Stage changes
runs git add, moving file changes into staging database index.
Commit snapshot
runs git commit, writing staged index into repository history.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
check status of modified and staged files
git statussee code differences in files staged for commit
git diff --staged05 / CHECK YOURSELF
Could you explain The Staging Area to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in Git & collaborationRemotes & Trackingyour copy vs everyone's copy