The Three Trees Architecture
Git manages your files through three distinct stages: the Working Directory, the Staging Area, and the Repository.
The Three Trees Architecture
To master Git, you must understand its architecture. Git doesn't just save files directly to history; it passes them through three distinct 'trees' (or areas).
1. **The Working Directory**: The physical files you see and edit on your computer's hard drive.
2. **The Staging Area (Index)**: A pre-commit holding area. It tracks what will go into your *next* snapshot.
3. **The Repository (HEAD)**: The .git folder where Git permanently stores all your committed snapshots.
Why it matters
The Staging Area is Git's superpower. It allows you to selectively choose exactly which changes go into the next commit, rather than forcing you to save everything at once.
For example, if you fix a bug in auth.js and update a logo in header.css, you can stage and commit them as two separate, logical units, even if you did the work at the same time.
How files move between them
When you edit a file, it starts modified in your **Working Directory**.
You use git add to move changes to the **Staging Area**. At this point, the changes are tracked and ready to be committed.
Finally, git commit takes everything in the Staging Area and wraps it into a permanent snapshot in the **Repository**, moving the HEAD pointer to this new snapshot.
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
- Working Directory = your messy desk.
- Staging Area = the podium where you arrange things for the photo.
- Repository = the photo album of permanent snapshots.
Done with this concept?
Mark it complete to track your progress. No login needed.