Git Status
The git status command shows the current state of the working directory and staging area. It answers three key questions:
- Which files have been changed?
- Which changes are staged (ready to commit)?
- Which files are brand new and not yet tracked by Git?
git status does not make any changes — it is purely a read-only command used to inspect what is happening in the repository. It is one of the most frequently used Git commands.
Syntax
git statusUnderstanding the Output
The output of git status can look different depending on the current state of the project. Let's go through each possible scenario.
Scenario 1 — Clean Working Directory (Nothing to Commit)
When all changes have been committed and nothing new has been changed:
On branch main
nothing to commit, working tree clean
This means the working directory matches the last commit exactly — no modifications, no new files.
Scenario 2 — Untracked Files
After creating a new file that Git has never seen before:
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
nothing added to commit but untracked files present (use "git add" to track)
Git sees the file but is not tracking it yet. It needs to be added with git add.
Scenario 3 — Modified Files (Not Staged)
When a previously committed file has been changed but not yet staged:
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.html
Scenario 4 — Staged Files (Ready to Commit)
After running git add on a file, it appears in the "Changes to be committed" section:
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: index.html
Scenario 5 — Mixed State (Staged + Unstaged + Untracked)
A real-world scenario where multiple types of changes exist at once:
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: style.css
Changes not staged for commit:
modified: index.html
Untracked files:
about.html
Reading this output: style.css is staged and ready to commit. index.html was modified but not yet staged. about.html is a brand new file not yet tracked.
Practical Example — Step by Step
# Start: empty Git repo
git status
# Output: nothing to commit, working tree clean
# Create a new file
echo "Hello World" > hello.txt
git status
# Output: Untracked files: hello.txt
# Stage the file
git add hello.txt
git status
# Output: Changes to be committed: new file: hello.txt
# Commit the file
git commit -m "Add hello.txt"
git status
# Output: nothing to commit, working tree clean
# Modify the file
echo "How are you?" >> hello.txt
git status
# Output: Changes not staged for commit: modified: hello.txt
Short Status Output
For a more compact view, the -s (short) flag can be used:
git status -sSample output:
M index.html
M style.css
?? about.html
The two columns represent: Staging Area (left) and Working Directory (right).
| Symbol | Meaning |
|---|---|
?? | Untracked file |
A | New file added to staging area |
M (left column) | File modified and staged |
M (right column) | File modified but NOT staged |
D | File deleted |
Checking Status of a Specific File or Folder
Status for a specific file can be checked by passing its name:
git status index.htmlgit status with Branch Information
The output also shows the current branch name and whether it is ahead or behind the remote:
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
(use "git push" to publish your local commits)
This means 2 local commits have not been pushed to GitHub yet.
Summary
git status is the go-to command for understanding what is happening in the repository at any moment. It clearly shows which files are untracked, which are modified, and which are staged and ready to commit. Running git status frequently is a best practice — it helps avoid mistakes and keeps the workflow clear.
