What the staging area is
Git has a middle step between editing a file and committing it. Knowing it explains most confusing messages.
Three places
- Your working folder is the files you see and edit.
- The staging area (also called the index) is a list of the changes that will go into the next commit.
git addcopies a change into it. - The commits are the saved history.
git committurns the staging area into a new commit.
You can stage part of your work and commit only that part. The rest stays in the folder, not yet saved.
The two letters in git status --short
git status --short prints two columns before each file name. The first is the staging area compared with the last commit. The second is your folder compared with the staging area.
| You see | It means |
|---|---|
M (M, then a space) | Modified and staged |
M (space, then M) | Modified, not staged |
MM | Staged, then changed again after staging |
A | New file, staged |
?? | Not tracked by Git |
UU | Both sides changed it (merge conflict) |
The situations on this site show real examples: the page about unstaging a file prints M and ?? and the conflict page prints UU.
The commands
git add <file>stages a file.git restore --staged <file>takes it out of the staging area without touching the file.git restore <file>throws away your folder changes for that file.git diffshows folder against staging area;git diff --stagedshows staging area against the last commit.
Why does Git not simply commit all my changes?
Because it lets you build clean commits: one commit for one idea.
What does git commit -a do?
It stages changes to files that Git already tracks and commits them in one step. It does not add new files.
Sources
- Git documentation: git-reset (git-scm.com/docs/git-reset)
- Git documentation: gitrevisions (git-scm.com/docs/gitrevisions)
- Git documentation: git-config, settings gc.reflogExpire and gc.reflogExpireUnreachable (git-scm.com/docs/git-config)
- Git documentation: git-revert (git-scm.com/docs/git-revert)
Read on 14 November 2026.
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.