MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
The Three Trees: Working Directory, Staging Area & Git Repository0%
Study Materials
Git & GitHub BasicsProgress 0%
1.1What is Version Control? (Local, Centralized vs Distributed VCS)1.2Why Git? History, Architecture & Core Benefits1.3The Three Trees: Working Directory, Staging Area & Git Repository1.4Installing Git and Initial Configuration (git config user.name / email)
HomeTutorialsGit & GitHub BasicsThe Three Trees: Working Directory, Staging Area & Git Repository
Installing Git and Initial Configuration (git config user.name / email)

The Three Trees: Working Directory, Staging Area & Git Repository

Beginner12 min read•Updated: 2026-09-15•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

The single most important mental model for understanding Git is the Three States (or Three Trees) Architecture. Almost every Git command moves files between these three distinct areas.


1. The Three Sections of a Git Project

Git manages your project files through three primary zones:

Visual Architecture & Process Flow

How data and code flow step-by-step

Flowchart
Step 1
| that you edit in | -----
Step 2
| for next snapshot | -----
Step 3
| history (snapshots) |

1. The Working Directory (Working Tree)

  • This is the physical folder on your computer filesystem where your project files live.
  • When you open files in VS Code, modify CSS, or add images, you are directly editing the Working Directory.
  • Changes here are untracked or modified, but not yet protected by Git's historical snapshot engine.

2. The Staging Area (The Index)

  • The Staging Area (historically called the Index) is a file located at .git/index.
  • It acts as an intermediate scratchpad where you assemble and curate the exact changes you want to include in your next commit.
  • Staging gives you precise control: if you modified 5 files, you can choose to stage only 2 of them to create a focused, logical commit.

3. The Git Repository (.git directory)

  • This is the permanent vault where Git stores the metadata and object database for your project.
  • When you run git commit, the contents currently in the Staging Area are permanently recorded as a snapshot commit object.
  • The .git directory is what gets copied when you clone a repository.

2. File Status Lifecycle

Within the Working Directory, files oscillate between two high-level states: Untracked and Tracked. Tracked files can be Unmodified, Modified, or Staged:

Visual Architecture Blueprint
+------------- Edit the file ------------+
                 |                                        |
                 v                                        |
+-------------------+      git add      +-------------------+    git commit   +-------------------+
|     Untracked     | ----------------> |      Staged       | --------------> |    Unmodified     |
| (Brand new file)  |                   | (Ready to commit) |                 |  (Committed state)|
+-------------------+                   +-------------------+                 +-------------------+
                                                  ^                                     |
                                                  |                                     |
                                                  +--------- git add (re-stage) --------+
                                                  |                                     |
                                                  v                                     |
                                        +-------------------+                           |
                                        |     Modified      | <--- Modify tracked file -+
                                        | (Changed on disk) |
                                        +-------------------+

3. Practical Terminal Walkthrough

Let's see how files transition between states using standard terminal commands:

1# 1. Check current status
2git status
3# Output: Untracked files: new_feature.py
4 
5# 2. Move file from Working Directory to Staging Area
6git add new_feature.py
7 
8# 3. Check status again
9git status
10# Output: Changes to be committed: new file: new_feature.py
11 
12# 4. Move staged snapshot into the permanent Git Repository
13git commit -m "feat: implement user authentication flow"
14# Output: [main 3a89e12] feat: implement user authentication flow
15# 1 file changed, 45 insertions(+)
16 
17# 5. Check status after commit
18git status
19# Output: nothing to commit, working tree clean

4. Why Does Git Have a Staging Area?

Other systems (like SVN or Mercurial) often commit directly from the working directory. Why did Git invent the Staging Area?

  • Crafting Atomic Commits: You can group related modifications together. If you fixed a typo in index.html and wrote a new database migration in db.sql, you shouldn't bundle them into one commit. You stage and commit index.html first, then stage and commit db.sql.
  • Reviewing Diffs Before Saving: You can inspect git diff --staged to verify exactly what is about to enter history before finalizing the commit.

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What are the three primary areas in Git's architecture?
Question 2
What Git command moves modified or untracked files into the Staging Area?
Question 3
What is the main benefit of having a Staging Area rather than committing all working tree changes automatically?
Question 4
Where does Git physically store all committed historical snapshots and objects on your machine?
Question 5
After running git commit -m "Add new page", what is the state of the committed file in the working directory?
Next Lesson

Installing Git and Initial Configuration (git config user.name / email)

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Why Git? History, Architecture & Core BenefitsInstalling Git and Initial Configuration (git config user.name / email)

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Git & GitHub Basics with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext