What are the three stages of a file in Git?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Git & GitHub topics. It also reveals how well you can explain technical ideas to non-experts.
Answer
Git has three main areas where files can exist: (1) Working Directory (Working Tree): the actual files on your disk that you edit. Changes here are untracked by Git until you explicitly add them. Files can be untracked (new files Git has never seen) or modified (tracked files that have changed since last commit); (2) Staging Area (Index): a preparation area between the working directory and the repository. You explicitly choose which changes to include in the next commit by running git add. The staging area lets you craft precise commits — you can stage only part of a file's changes, stage some files but not others. git add file.txt moves changes to staging; (3) Repository (.git directory): the permanent, versioned history. git commit takes everything in the staging area and creates a commit in the repository. The transition: Working Directory → (git add) → Staging Area → (git commit) → Repository. View which stage files are in: git status. View staged changes: git diff --staged. View unstaged changes: git diff.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.