Checking Status
git status answers the question "what's going on in my repository right now?" — which branch you're on, what you've changed, what's ready to commit, and what Git isn't tracking. Experienced users run it constantly, before and after almost every other command.
A clean working tree
Right after a commit, with nothing changed, the status is short:
git status
On branch main nothing to commit, working tree clean
"Working tree clean" means every tracked file matches the last commit and there are no new files. It's the safe state to be in before switching branches or pulling in other people's work.
Reading a busy status
Sam edits one recipe, stages it, edits another without staging, and creates a new file:
echo "Pancakes: flour, milk, eggs, a pinch of salt" > pancakes.txt git add pancakes.txt echo "Omelette: eggs, butter, chives" > omelette.txt echo "Granola: oats, honey, nuts" > granola.txt git status
On branch main Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: pancakes.txt 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: omelette.txt Untracked files: (use "git add <file>..." to include in what will be committed) granola.txt
The output has up to three sections, always in this order:
| Section | Meaning | Next step |
|---|---|---|
| Changes to be committed | Staged — these go into the next commit | git commit, or unstage with git restore --staged |
| Changes not staged for commit | Tracked files edited since they were last staged or committed | git add to stage, or git restore to discard |
| Untracked files | New files Git has never tracked | git add to start tracking, or list them in .gitignore |
A file can be in two sections
Staging records the file as it is at that moment. Edit it again afterwards and it appears twice:
echo "Serves 4" >> pancakes.txt
git status
On branch main Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: pancakes.txt 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: omelette.txt modified: pancakes.txt Untracked files: (use "git add <file>..." to include in what will be committed) granola.txt
The staged version has the salt; the working tree also has "Serves 4". If you commit now, only the salt goes in. Run git add pancakes.txt again to stage the newer version.
Short format
-s (--short) gives one line per file — great once you know the codes:
git status -s
M omelette.txt MM pancakes.txt ?? granola.txt
Each line starts with two columns: the left one is the staging area, the right one is the working tree.
| Code | Meaning |
|---|---|
M (green M, left) | Modified and staged |
M (right) | Modified, not staged |
MM | Staged, then modified again |
A | New file, staged (added) |
D / D | Deleted (staged / not staged) |
R | Renamed |
?? | Untracked |
UU | Unmerged — a merge conflict to resolve (lesson 25) |
Add -b to include the branch name on the first line:
git status -sb
## main M omelette.txt MM pancakes.txt ?? granola.txt
Status and branches
The first line always names the branch. Once your repository is connected to a server (lesson 32), status also compares your branch with the server's copy — for example "Your branch is ahead of 'origin/main' by 2 commits", meaning you have commits you haven't pushed yet. During a merge, rebase or cherry-pick, status says so and tells you how to continue or abort; when you're unsure what state you're in, status is the first thing to check.
Status in a subfolder
Run inside a subfolder, git status still reports on the whole repository, but shows paths relative to where you are. If you want just one folder, give it as an argument:
mkdir desserts
echo "Brownies: chocolate, butter, sugar" > desserts/brownies.txt
git status -s desserts
?? desserts/
Notice that Git shows the folder (desserts/) rather than each file inside it, because the whole folder is untracked.
Try it yourself
In a repository with at least one commit, produce each of these short-status codes in turn and check them with git status -s: ??, A , M, M and MM.