What is the difference between Git’s working tree, staging area, and commits?
Quick answer
The working tree is the files you currently edit on disk. The staging area, or index, holds changes selected for the next commit. A commit records changes in repository history. Use git status to see paths that differ across these layers, git diff for unstaged changes, git diff --cached for staged changes, and git log to inspect recorded commits. [S1] [S2] [S3]
The question, the details, the next step.
A practical checklist
Run
git statusto distinguish staged, unstaged, and untracked paths.Use
git diff -- path/to/fileto inspect unstaged content.Use
git diff --cached -- path/to/fileto inspect staged content before committing.Compare both diffs if a file has a mixture of staged and unstaged edits.
After committing, inspect
git logand check status for remaining changes.
A few more useful answers
Does saving a file stage it?
No. Saving edits the working-tree file; staging is a separate selection step. Check the difference with git diff.
What does Git report as untracked?
git status reports untracked paths separately from paths with differences between the commit, index, and working tree. Review its output to see which paths it identifies as untracked. [S1]
Sources
References used for this guide.
- [S1] Git status: differences among commit, index, and working tree git-scm.com · Checked
- [S2] Git diff: inspect working-tree and staged changes git-scm.com · Checked
- [S3] Git log: inspect commit history git-scm.com · Checked
