# Git Mental Model ## Three places your files can be Git tracks your project through three distinct areas, and understanding this model is what makes every Git command make sense — memorizing commands without it just produces confusion the first time something doesn't behave as expected. ``` Working Tree → Staging Area → Repository (commit history) (your actual (what you've (permanent, files, as you marked ready recorded edit them) to commit) snapshots) ``` - **Working tree** — the actual files on disk, exactly as you're editing them right now. - **Staging area** (also called "the index") — a holding area for changes you've deliberately marked as ready to be committed. This is Git's most distinctive design choice: you don't commit "everything that changed," you commit "exactly what you staged." - **Repository** — the permanent, recorded history of every commit ever made — this is what `git log` shows you. ## Why `git add` exists at all A change starts in your working tree. `git add ` moves it (conceptually — the mechanics are more subtle, but this framing is enough for now) into the staging area. `git commit` takes EVERYTHING currently staged and permanently records it as a new snapshot in the repository's history. This two-step process (stage, then commit) exists so you can build up a commit DELIBERATELY — staging exactly the related changes that belong together, even if your working tree currently has other, unrelated changes you're not ready to commit yet. ## Core vocabulary - **Commit** — one permanently recorded snapshot, with a message describing what changed and why, and a unique identifier (a hash). - **Branch** — a movable pointer to a specific commit, letting you develop something (a "feature branch") without affecting the main line of history until you're ready to combine it back in (Module 4). - **HEAD** — Git's pointer to "which commit you're currently looking at" — almost always the tip of whichever branch you have checked out. - **Remote** — a reference to another copy of the same repository, usually hosted somewhere else (Module 5). ## Instructor Notes **Lesson goal:** Establish the three-area model BEFORE any commands — same "model before syntax" pedagogy as ROOT 01's process model and ROOT 05's Kubernetes mental model. Every subsequent Git command should be explainable in terms of moving something between these three areas. **Approximate timing:** 15 minutes read; 10 minutes live, ideally with a literal diagram drawn live (whiteboard or shared screen) showing files moving between the three areas. **Common misconception to watch for:** assuming `git commit` commits every changed file automatically — this is the single most common Git surprise for beginners, and it's exactly what Module 3's Lab will make concrete. **Discussion question:** "Why would you ever WANT to stage only some of your changes, not all of them?" (Answer: to build one commit about ONE logical change, even if your working tree currently has several unrelated edits in progress.)