The cheap, safe, always-run-first command.
Show the state of the working tree and index relative to HEAD: what's staged, what's modified-but-unstaged, what's untracked, what branch you're on, how it relates to its upstream. Read-only and cheap — run it constantly.
Status reads three things and diffs them: HEAD's tree, the index, and the working tree. 'Staged' = differences between HEAD and the index. 'Unstaged' = differences between the index and the working tree. 'Untracked' = files in the working tree that the index has never seen.
git status [<options>] [--] [<pathspec>...]| Flag | What it does |
|---|---|
-s, --short | Compact output. Two columns: index state, working tree state. |
-b, --branch | Show branch + upstream tracking info even in short form. |
--porcelain[=<v>] | Stable, machine-readable format. Use this in scripts. |
-u, --untracked-files[=mode] | Control how aggressively to scan for untracked files. no is fastest; all lists every file in untracked dirs. |
--ignored | Also show ignored files. Helpful when figuring out why something isn't being tracked. |
--ahead-behind | Show how many commits ahead/behind upstream you are. |
--porcelain output is parseable and won't change between Git versions.$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
modified: src/main.c
Untracked files:
notes.todo$ git status -sb
## main...origin/main
M src/main.c
?? notes.todobuild/output.log tracked?$ git status --ignored | grep build/
build/$ test -z "$(git status --porcelain)" && echo clean || echo dirtygs='git status -sb' if you type it more than ten times a day — and you will.--porcelain for any script. The non-porcelain output is for humans and will change between versions.core.fsmonitor and core.untrackedCache.status won't show what the hook will reject.core.untrackedCache=true.Hit each option, then Check answers. Score is recorded; Next is always open.