git init and the Three Areas
9 min read
Creating a Repository
A Git repository is a folder that Git tracks. Running git init creates a hidden .git/ directory that stores all history, configuration, and objects. Never delete or manually edit .git/.
bash
mkdir my-project
cd my-project
git init
# Initialized empty Git repository in .../my-project/.git/The Three Areas
Understanding Git's three areas is the single most important mental model in this entire course. Every file lives in exactly one of these at any moment:
- Working Directory — the files you see and edit on disk. Changes here are untracked or modified but not yet staged.
- Staging Area (Index) — a holding zone where you assemble the exact snapshot you want to commit.
git addmoves changes here. - Repository (.git/) — the permanent, compressed history.
git commitmoves the staged snapshot here.
text
Working Directory --> Staging Area --> Repository
(edit files) (git add) (git commit)The staging area lets you craft precise commits. You might change five files but only stage three, creating a focused commit that is easier to review and revert.
Ready to test yourself?
Practice Git & GitHub— quiz & coding exercises