The Three Git Zones & Checking History
Before you start branching, you need to understand how Git sees the files on your computer. Git operates across three main zones:
- Working Directory: This is your actual project folder on your computer. You can see, edit, and delete files here normally.
- Staging Area (The Index): This is your "loading dock." When you modify a file, Git notices, but it won't save it until you "stage" it. Think of this as putting items into a shopping cart before checking out.
- Local Repository: This is where Git stores your permanent checkpoints (commits). Once you commit, your changes are safely logged into Git's history book.
Moving Files Through the Zones
# Step 1: Put a modified file into the Staging Area (the shopping cart)
git add filename.txt
# Shortcut: Put ALL modified files into the Staging Area
git add .
# Step 2: Permanently save everything in the Staging Area as a checkpoint
git commit -m "A short message describing what you changed"
Checking Your History: Git Log
If you ever get lost or want to find the ID number of an old save point, you can look at your history log.
# View the full list of past saves, who made them, and when
git log
# A beginner-friendly, clean, compact view of your history timeline
git log --oneline --graph --decorate