Course contentsShow
← Software Engineering
Lesson 46 of 1,9332. Version Control with GitFree lesson

The Three States: Working Directory, Staging Area, and Repository

Understanding Git's fundamental architecture of modified, staged, and committed states.

The Three States: Working Directory, Staging Area, and Repository

What you'll learn: How Git organizes your files across three distinct states to give you precise control over what gets saved and when.

The Three-Stage Architecture

Git doesn't just save everything all at once. Instead, it uses a three-stage system that lets you carefully choose which changes become permanent:

  1. Working Directory — This is your actual project folder where you edit files. Changes here are modified but not yet tracked by Git. Think of this as your desk where you're actively working on drafts.

  2. Staging Area — When you're happy with some changes, you move them here to prepare them for saving. Files in this state are staged. This is like putting finished drafts into an envelope before mailing them — you've decided these changes are ready, but haven't committed yet.

  3. Repository — When you commit, staged changes move here permanently. These are committed changes stored in Git's history. This is your filing cabinet — once filed, these changes are part of your project's permanent record.

Why Three States?

This system gives you flexibility. You might modify ten files but only want to save five right now. You stage those five, commit them with a descriptive message, then stage and commit the other five separately later. This keeps your project history organized and meaningful.

The Flow

The typical flow: modify files in your working directory → stage the ones you want to save → commit them to the repository. You can repeat this cycle as many times as needed throughout your workday.

Key Takeaway: Git's three states (modified, staged, committed) give you fine-grained control over what changes become part of your project's permanent history, allowing you to organize your work logically rather than saving everything at once.