dev.log / syntax diaries

Practical code notes, tools, and guided learning for developers.

Practical guides, developer tools, and tutorials for modern web developers, with the same focused tone across writing, utilities, and learning tracks.

BlogToolsTutorialsAboutContactAdmin Login
Privacy PolicyTerms of ServiceCookie Policy

© 2026 The Syntax Diaries · System_Operational

The Syntax Diaries logoThe Syntax Diaries
BlogToolsTutorialsAbout
build log live
Tutorial / Git
Fundamentals25 minutesbeginner

Git's Three States

Understanding the three fundamental states in Git: working directory, staging area, and repository.

On This Page

Learning ObjectivesThe Three States of Git1. Working DirectoryKey Characteristics2. Staging Area (Index)Purpose and FeaturesWhat It DoesCommon Commands3. Git Repository (.git directory)Repository ContentsKey FeaturesUnderstanding File LifecycleUntracked FilesModified FilesStaged FilesCommitted FilesCommon Commands ReferenceWorking Directory CommandsStaging Area CommandsRepository CommandsAdvanced CommandsKnowledge CheckWhat's Next?Additional Resources

Git's Three States#

Understanding the three fundamental states in Git: working directory, staging area, and repository.

Learning Objectives#

  • Understand the three fundamental states in Git: Working Directory, Staging Area, and Repository
  • Learn how files move through different states in Git
  • Master the concepts of staging and committing changes
  • Understand the role of the .git directory in managing your project

The Three States of Git#

Git manages your files through three main states. Understanding these states is crucial for working effectively with Git. Each state serves a specific purpose in the version control process:

1. Working Directory#

The Working Directory is where you actively make changes to your project files. It's also known as the "working tree" and represents the immediate state of your project's files.

Key Characteristics#

          - Contains the actual files you're currently working on

              Files can be modified without affecting Git's version control

              Changes are initially "untracked" by Git

2. Staging Area (Index)#

          The Staging Area, also known as the "index," is a middle ground between your working
          directory and the Git repository. It's where you prepare changes for committing.

Purpose and Features#

What It Does#

                •

                  Prepares content for next commit
              - •

                  Reviews changes before committing
              - •

                  Organizes changes into commits

Common Commands#

              - git add

                  Add files to staging
              - git reset

                  Remove from staging

3. Git Repository (.git directory)#

The Git Repository is where Git stores all the snapshots of your project's history. It's contained within the .git directory and is the heart of Git's version control system.

Repository Contents#

              - •

                  Complete history of commits
              - •

                  Project configuration
              - •

                  Branch information

Key Features#

              - •

                  Permanent storage
              - •
                Commit tracking
              - •
                Version history

Understanding File Lifecycle#

Files in Git go through various states throughout their lifecycle. Understanding these states helps you manage your changes effectively:

Untracked Files#

New files that Git doesn't yet track. Use

                git add

              to begin tracking them.

Modified Files#

Tracked files that have changed since the last commit. Stage them with

                git add

              to prepare for committing.

Staged Files#

Modified files marked for inclusion in the next commit. Use

                git commit

              to save them to the repository.

Committed Files#

Files safely stored in the Git repository. These changes are now part of your project's history.

Common Commands Reference#

Here are the essential Git commands you'll use when working with different states:

Working Directory Commands#

            - git clean

                Remove untracked files

Staging Area Commands#

            - git add <file>

                Stage specific file changes
            - git add .

                Stage all changes
            - git reset <file>

                Unstage changes

Repository Commands#

            - git commit -m "message"

                Commit staged changes
            - git log

                View commit history
            - git show

                View details of commits

Advanced Commands#

            - git diff --staged

                View staged changes
            - git rm --cached <file>

                Untrack a file
            - git restore --staged <file>

                Modern way to unstage changes

Knowledge Check#

Before moving on to the next lesson, make sure you can answer these questions:

          - 1. What are the three main states in Git?

Think about where files live and how they move between states. - 2. What is the purpose of the staging area?

Consider why we don't commit directly from the working directory. - 3. Which command moves changes to the staging area?

Remember the basic Git commands we covered. - 4. What happens when you commit changes?

Think about where committed changes are stored and how they're managed. - 5. What is the difference between tracked and untracked files?

Consider how Git manages new files versus files it's already tracking.

What's Next?#

Now that you understand Git's three states and how files move between them, you're ready to learn about the repository structure in detail. In the next lesson, we'll explore:

          - The structure of the .git directory

              How Git stores and manages objects

              Understanding references and their importance

              Basic Git architecture and workflow

Additional Resources#

        To deepen your understanding of Git states and file lifecycle:

Official Git Documentation

                Detailed explanation of Git's basic concepts
          - Git Command Reference

                Complete documentation of Git commands

Previous

Git Installation & Setup

Next

Git Repository Structure