git status — Reading the Working Tree
git status is the command you will run more than any other. It answers the question “what is going on in my repository right now?” — and learning to read its output precisely is one of the most valuable Git skills you can develop.
The anatomy of git status output
Section titled “The anatomy of git status output”Run git status in your git-practice folder. You will see one of several possible states depending on what you have done. Here is a full example with something in every section:
On branch mainYour branch is up to date with 'origin/main'.
Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: pine-ridge.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: summit-challenge.txt
Untracked files: (use "git add <file>..." to include in what will be committed) river-canyon.txtThis output has four sections. Each tells you something different.
Section 1: Branch and remote status
Section titled “Section 1: Branch and remote status”On branch mainYour branch is up to date with 'origin/main'.On branch main— which branch you are currently on. This changes when you switch branches in Module 03.Your branch is up to date with 'origin/main'— appears when the repo is connected to GitHub. It tells you whether your local history is ahead of, behind, or in sync with the remote. You will see this in Module 05.
In a local-only repository, you will only see the branch line.
Section 2: Changes to be committed (staged)
Section titled “Section 2: Changes to be committed (staged)”Changes to be committed: modified: pine-ridge.txtThese files are in the staging area. They have been added with git add and will be included in the next commit. The status label tells you what kind of change it is:
| Label | Meaning |
|---|---|
new file: | A previously untracked file being committed for the first time |
modified: | A tracked file with changes staged |
deleted: | A tracked file that has been deleted and the deletion is staged |
renamed: | A file that has been moved or renamed |
Section 3: Changes not staged for commit (unstaged modifications)
Section titled “Section 3: Changes not staged for commit (unstaged modifications)”Changes not staged for commit: modified: summit-challenge.txtThese files are tracked by Git and have been modified, but the changes have not been staged yet. Running git add summit-challenge.txt would move this file up to the “Changes to be committed” section.
A file can appear in both sections simultaneously — if you stage a file and then make additional edits, the staged version and the newer working-tree version are different. Git tracks both separately.
Section 4: Untracked files
Section titled “Section 4: Untracked files”Untracked files: river-canyon.txtThese files exist in your working tree but Git has never been told to track them. They will not be committed until you stage them with git add.
A file stays untracked forever until you explicitly add it. This is useful: you can keep files in your project folder that you never want to commit — logs, editor files, generated output — by simply never staging them. In Module 07 you will learn to use .gitignore to prevent untracked files from cluttering this section.
The clean state
Section titled “The clean state”When there is nothing to report, you see:
On branch mainnothing to commit, working tree cleanThis is the ideal state between work sessions. Every change has been committed, and the working tree perfectly matches the latest commit.
A short flag: git status -s
Section titled “A short flag: git status -s”The -s flag gives a compact summary:
git status -sM pine-ridge.txt M summit-challenge.txt?? river-canyon.txtEach line is two columns:
- The left column shows the staging area status (staged changes)
- The right column shows the working tree status (unstaged changes)
??means untracked
The short format is useful when you have many files and want a quick scan. The long format (default) is better when you are learning or need to understand exactly what is happening.
Exercise
Section titled “Exercise”-
In your
git-practicefolder, modifypine-ridge.txtby adding a line. Create a new fileriver-canyon.txtwith any content. -
Stage
pine-ridge.txt:
git add pine-ridge.txt-
Run
git statusand identify all three sections: staged, unstaged (if you modify something further), and untracked. -
Edit
pine-ridge.txtagain after staging it. Rungit status. Observe that it now appears in two sections — the staged version is what you staged, and the unstaged modification is what you added afterward. -
Run
git status -sand match each line to the full output.
git statushas four sections: branch info, staged changes, unstaged modifications, and untracked files.- Staged files are in the staging area and will be included in the next commit.
- Unstaged files are tracked but have changes not yet added to the staging area.
- Untracked files are unknown to Git until you run
git add. - A file can appear in both staged and unstaged sections if you modify it after staging.
git status -sgives a compact two-column summary.- “Working tree clean” means everything is committed.
Next: git diff — seeing the exact line-by-line content of what changed, both in your working tree and in the staging area.