Skip to content

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.

Terminal window
git status

A repository can report several sections at once:

On branch master
No commits yet
Changes to be committed:
new file: ex.txt
Changes not staged for commit:
modified: ex.txt
Untracked files:
notes.txt

On 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.

Terminal window
git status --short

Each path has two status columns:

XY path
│└─ Y: Working Tree versus Staging Area
└── X: Staging Area versus recorded content

Useful 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.

Run status before and after a meaningful operation:

Terminal window
git status
# perform the intended Git operation
git status

Before 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.

  • Reading Changes not staged for commit as an error that prevents all commits. Staged content can still be committed while unstaged edits remain.
  • Reading AM backward. The first column is staging; the second is the Working Tree.
  • Treating ?? as a missing file. It means currently untracked.
  • Treating ahead by 2 commits as two changed files.
  • Assuming a clean Working Tree proves the branch is synchronized elsewhere.
git status → full, read-only state report
git status --short → compact two-column file-state report
first column → staged state
second column → Working Tree state
ahead/behind → commit comparison, not file changes
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.