Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Setup and Basics

git status command

Reference for git status: read staged, unstaged and untracked changes, the short and porcelain formats, the XY codes, branch info and options for scripts.

git status shows how the working tree and the index differ from HEAD, and which files Git does not track. It reports three groups: changes staged for the next commit, changes in tracked files that are not staged, and untracked files. It also tells you which branch you are on and how it compares with its upstream.

The command never changes your files or history. By default the output is written for people; the short (-s) and porcelain (--porcelain) formats are compact and the latter is meant for scripts.

Terminal
git status [-s] [-b] [--porcelain[=v1|v2]] [-u<mode>] [--ignored] [-z] [--] [<pathspec>...]

Try it

Bash Long and short output with every kind of change

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Untracked modes, ignored files and porcelain

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git status
git status -sb
git status --porcelain=v2 --branch -z
Option Description
-s, --short Two-column short format, one line per path.
-b, --branch Add a ## branch...upstream [ahead N, behind M] line to the short format.
--porcelain[=<v>] Stable, script-friendly output. Version 1 (default) matches the short format without color; version 2 adds more detail (modes, object IDs, rename scores).
--long The default human format.
-u[<mode>], --untracked-files[=<mode>] no, normal (collapse untracked directories, the default), or all (list every file).
--ignored[=<mode>] Also list ignored files (traditional, no, matching).
--ignore-submodules[=<when>] none, untracked, dirty, all.
-z NUL-terminate entries with no path quoting (implies porcelain v1 unless a format is given).
--show-stash Show how many stashes exist.
--ahead-behind / --no-ahead-behind Compute or skip the (potentially slow) comparison with the upstream.
--renames / --no-renames Detect renames between index and HEAD.
-v, --verbose Also show the staged diff (twice: the unstaged diff too).
--column Show untracked files in columns.
-- <pathspec> Limit the report to matching paths.

Short format codes. Each line is XY path. X compares the index with HEAD, Y compares the working tree with the index.

Code Meaning
M Modified
A Added
D Deleted
R Renamed (X only, old -> new)
C Copied
T Type changed (file to symlink)
U Unmerged: a conflict (UU both modified, AA both added, DU, UD, and so on)
?? Untracked
!! Ignored (with --ignored)
space Unchanged in that column

For example M is staged only, M is modified but not staged, MM is both, and AM is a new file that you edited again after adding.

Exit status: always 0 when it succeeds, even if there are changes. To test for cleanliness in a script use git status --porcelain and check whether the output is empty, or use git diff --quiet.

Usage notes

  • Use porcelain in scripts. The human format is localized (LANG) and changes between versions; --porcelain does not.
  • Large repositories. Status must compare timestamps and sizes of every tracked file. Enable core.fsmonitor and core.untrackedCache, or use -uno to skip the untracked scan, as described in Performance and Maintenance.
  • Ignored versus untracked. An ignored path never appears unless you ask; a tracked file that matches an ignore pattern is still tracked and shows its changes.
  • Nothing to commit is reported only when the index equals HEAD and there are no unstaged or untracked entries.
  • Rename detection in status compares only staged changes with HEAD. Unstaged renames show as a deletion plus an untracked file until you git add both sides.
  • Merge, rebase and bisect state appear in the long format with hints such as "You have unmerged paths" and which command continues or aborts the operation.
  • Optional file locks. git status may refresh the index and take the lock briefly; use GIT_OPTIONAL_LOCKS=0 in prompts and editor integrations that run it in the background.
  • Config. status.short, status.branch, status.showUntrackedFiles and status.aheadBehind set defaults.