Git Status
Before recording work, you need to know what Git would include, what remains
outside the staging area, and which new files Git has not begun tracking.
git status is a read-only safety check for those questions.
1. Read the full report
Section titled “1. Read the full report”git statusA repository can report several sections at once:
On branch masterNo commits yet
Changes to be committed: new file: ex.txt
Changes not staged for commit: modified: ex.txt
Untracked files: notes.txtOn branch master names the current branch. No commits yet means there is
no recorded commit; the two statements can both be true. The branch name may
vary with the repository’s configuration.
Changes to be committed lists content currently selected for the next
commit. Changes not staged for commit lists later Working Tree changes that
are not selected. Therefore, the same path can appear in both sections: one
version is staged and a different version remains in the Working Tree.
Untracked files lists paths Git does not currently track. An untracked file
is not included in the next commit simply because it exists in the project
directory. Treat this as a description of present state, not proof of every
action ever performed on the file.
The explanatory commands in the full report are suggestions. Read their effects before running them, especially any command that discards changes.
2. Read the two short-status columns
Section titled “2. Read the two short-status columns”git status --shortEach path has two status columns:
XY path│└─ Y: Working Tree versus Staging Area└── X: Staging Area versus recorded contentUseful examples:
| Output | Meaning |
|---|---|
?? notes.txt |
Currently untracked file. |
A ex.txt |
New file staged, with no later Working Tree edit. |
M ex.txt |
Tracked file modified only in the Working Tree. |
M ex.txt |
Modified content staged, with no later Working Tree edit. |
AM ex.txt |
New version staged and then modified again in the Working Tree. |
Spaces in these examples matter: a blank column means no change reported in
that comparison. In the disposable exercise, git status --short returned
AM ex.txt. The A describes the staged addition; the M describes the
newer, unstaged edit. The detailed staging commands come in the next lesson.
3. Branch information is separate from file state
Section titled “3. Branch information is separate from file state”Status may also say a branch is ahead or behind another branch it tracks.
Those numbers count commits in the comparison, not modified files. A branch
can be behind by one commit while the Working Tree is clean. The mechanics of
tracking and remote branches are taught later.
working tree clean means Git reports no pending file changes in its normal
status view. It does not mean the branch is synchronized with another branch,
and ignored files are not normally listed.
4. A safe routine
Section titled “4. A safe routine”Run status before and after a meaningful operation:
git status# perform the intended Git operationgit statusBefore a commit in a Laravel project, use the report to catch an accidentally staged configuration file, a missing test, or a newer edit that was never staged. Afterward, confirm that only the changes you intended remain.
5. Common mistakes
Section titled “5. Common mistakes”- Reading
Changes not staged for commitas an error that prevents all commits. Staged content can still be committed while unstaged edits remain. - Reading
AMbackward. The first column is staging; the second is the Working Tree. - Treating
??as a missing file. It means currently untracked. - Treating
ahead by 2 commitsas two changed files. - Assuming a clean Working Tree proves the branch is synchronized elsewhere.
6. Summary
Section titled “6. Summary”git status → full, read-only state reportgit status --short → compact two-column file-state reportfirst column → staged statesecond column → Working Tree stateahead/behind → commit comparison, not file changes7. Knowledge check
Section titled “7. Knowledge check”How can one file appear in both change sections?
Git has staged one version, then the Working Tree changed again.
What does AM ex.txt mean?
The file is staged as an addition and has a newer unstaged modification.
Can a clean Working Tree coexist with a branch that is behind?
Yes. File state and commit-position comparison are separate questions.