git status — Understanding the Working Directory
The git status command shows you the current state of your repository. It tells you:
- Which files are untracked (new, not yet known to Git)
- Which files are staged (ready to be committed)
- Which files are modified (changed but not yet staged)
The Three States
Every file in a Git repository can be in one of three states:
Untracked → Staged → Committed
↑ |
└─────────┘ (modify → stage again)
- Untracked: Git doesn't know about this file yet
- Staged: The file is in the staging area, ready for the next commit
- Modified: The file changed since the last commit but isn't staged yet
Try it!
The repository is already initialized. Your task:
- Create two files:
touch staged.txt untracked.txt - Stage only one:
git add staged.txt - Run
git statusto see the difference
Notice how staged.txt appears under "Changes to be committed" while untracked.txt appears under "Untracked files".
Why is this useful?
Before committing, always run git status to verify exactly what will go into your commit. It's the most common Git command — you'll use it constantly.