Skip to content

Reading git status

While working on a Git project, files can exist in different states.

Some files may be:

  • Newly created and still untracked.
  • Modified but not staged.
  • Staged and ready for the next commit.
  • Unchanged and matching the latest commit.

The command:

Terminal window
git status

gives us a summary of the repository’s current state.

It answers questions such as:

  • Which branch am I currently on?
  • Which changes are staged for the next commit?
  • Which tracked files have unstaged modifications?
  • Which new files are still untracked?
  • Is the Working Tree clean?

git status is a read-only command. It reports information but does not modify, stage, commit, or delete anything.

Suppose our project contains these three files:

auth.js
README.md
notes.txt

Their current states are:

  • auth.js is a new file that was added to the Staging Area.
  • README.md is already tracked but has been modified without running git add again.
  • notes.txt is a new file that Git has never tracked.

Running:

Terminal window
git status

may display:

On branch main
Changes to be committed:
new file: auth.js
Changes not staged for commit:
modified: README.md
Untracked files:
notes.txt

Staged

Status section
Changes to be committed
Example
new file: auth.js

Unstaged

Status section
Changes not staged for commit
Example
modified: README.md

Untracked

Status section
Untracked files
Example
notes.txt

Clean

Status output
nothing to commit, working tree clean
Meaning
No staged, unstaged, or untracked changes to report
On branch main

This line tells us that the currently checked-out branch is main. It simply identifies the branch we are currently working on.

Changes to be committed:
new file: auth.js

This section lists changes currently stored in the Staging Area.

They are prepared to enter the next commit if we run git commit.

In this example, auth.js is a new file whose current version has already been staged.

A beginner-friendly meaning is:

These are the changes currently selected for the next snapshot.

Changes not staged for commit:
modified: README.md

This section lists tracked files that were modified in the Working Tree, but whose latest modifications have not been added to the Staging Area.

In this example, Git already tracks README.md, but the current modification is available only in the Working Tree.

A beginner-friendly meaning is:

Git knows this file, but its latest change has not been selected for the next snapshot.

Untracked files:
notes.txt

This section lists new files that Git can see in the Working Tree but has never started tracking.

The file exists on disk, but it is not currently included in the Staging Area or repository history.

A beginner-friendly meaning is:

The file exists, but Git has not been asked to include it yet.

Do not say that Git cannot see the file. Git can see it and reports it as untracked.

A single file can have both staged and unstaged changes at the same time.

For example:

  1. Create auth.js.
  2. Stage its current version:
Terminal window
git add auth.js
  1. Edit auth.js again without running git add a second time.
  2. Run:
Terminal window
git status

Git may display:

Changes to be committed:
new file: auth.js
Changes not staged for commit:
modified: auth.js

This is not a contradiction.

It means Git currently knows about two versions of the file:

  • The version captured earlier by git add is in the Staging Area.
  • The newer modification exists only in the Working Tree.

The second edit was not staged automatically.

To include the newest version in the next commit, we would need to run:

Terminal window
git add auth.js

again.

This reinforces an important rule:

git add stages the file’s contents as they exist at the moment the command is executed. Later modifications remain unstaged until git add is executed again.

If the Working Tree, Staging Area, and latest commit all match, git status displays:

nothing to commit, working tree clean

This means:

  • There are no staged differences waiting for a commit.
  • There are no unstaged modifications.
  • There are no untracked files that Git needs to report.

It does not mean that the project contains no files. It means there are no currently reported changes.

Interview question: What is the difference between git status and git diff?

Section titled “Interview question: What is the difference between git status and git diff?”

git status summarizes the state of the repository and tells us which files are staged, unstaged, or untracked. The default git diff shows the actual line-by-line differences between the Working Tree and the Staging Area.

git status git diff
Provides a summary of file states. Displays the actual content differences.
Lists filenames and categories. Displays changed lines inside tracked files.
Reports staged changes. The default command does not show staged changes.
Reports unstaged tracked changes. Shows unstaged changes line by line.
Reports untracked filenames. Normally does not show the contents of untracked files.
Does not show exactly which lines changed. Shows added, removed, and unchanged context lines.
Does not modify anything. Does not modify anything.

git status summarizes information from both important comparisons:

  • Working Tree ↔ Staging Area: identifies unstaged modifications.
  • Staging Area ↔ HEAD: identifies changes prepared for the next commit.
  • It also reports new files that are not tracked in the Index.

By contrast, the default:

Terminal window
git diff

focuses on one comparison:

Working Tree ↔ Staging Area

It displays the actual unstaged differences line by line.

To inspect the actual differences between the Staging Area and HEAD, the learner can use the command explained in the next lesson:

Terminal window
git diff --staged
git status
Shows where every reported change currently stands.
git diff
Shows what changed line by line between the Working Tree and Staging Area.