Working Directory, Staging Area, and Repository

Git conceptually separates your project into three important areas. The working directory contains the files you are currently editing. The staging area, also called the index, contains changes selected for the next commit. The repository contains committed snapshots.

This separation lets you create focused commits. For example, if you modify three files but only one change is ready, you can stage only that file and commit it.

Git's Three Areas
Stage Selectively
git status
git add src/auth.js
git status
git commit -m "Add authentication validation"
💡 Only src/auth.js is staged, so the commit can contain that logical change without automatically including unrelated modifications.
Key Takeaways
  • Staging is a preparation step, not the same as committing.
  • Use selective staging to keep commits focused and reviewable.
  • The repository contains committed snapshots rather than an editable working copy.
Knowledge Check

Which Git area contains changes selected for the next commit?