Ravindra BagaleCourses & study guides

Chapter 2: Git Fundamentals

2.5 The staging area — mental model

Think of three trays on your desk: working folder, staging area, and Git history.

  1. Working tree: files you are still editing — unsaved Git state.
  2. Staging area: files ready for the next commit — git add.
  3. Commit history: commits already recorded — git commit.

You can edit five files but stage only two. The commit then contains only those two. That control is the point of staging.

Command Effect
git status Show untracked, modified, and staged files
git add <file> Put one file into the staging area
git add . Stage everything new/changed under this folder (dangerous if secrets exist)
git restore --​staged <file> Unstage (keep file edits)
git diff Show unstaged edits
git diff --​staged Show what the next commit will include

Why check status first. Blind git add . stages .env, key files and node_modules if you forgot .gitignore.

Ravindra Bagale's Tip

Khup students thambat nahi — thodach git add . aani commit. Secrets history madhe jatat. Nehmi aadhi git status bagha; nantar specific files git add. Bilkul visru naka.

Steps — practise staging carefully

  1. Change two files in your hello repo (for example app.py and README.md).
  2. Run git status — both should be modified.
  3. Run git add app.py only.
  4. Run git status again — one staged, one not.
  5. Commit with a message only about the API change.
  6. Stage and commit the README separately with its own message.

What you see: two commits in git log, each with a focused message. That habit helps code review later.