git status --porcelain=v1, git status -s, git status -b, --untracked-files=no
git status [<options>] [--] [<pathspec>...]
git status -s
git status --porcelain=v1
git status --porcelain=v1 -b
git status --porcelain=v1 --untracked-files=noPrint a machine-stable view of staged, unstaged, and untracked paths.
| Parameter | Description |
|---|---|
--porcelain=v1 | The stable v1 porcelain format. Prefer this in scripts over the long format or a raw -s when you need a documented interface. |
-b / --branch | With porcelain, print a ## line for the current branch before the path lines. |
--untracked-files=no | Do not list untracked files. -u no is the short form used as --untracked-files=no in the example. |
Returns: Status lines on standard output. An empty porcelain list means a clean worktree and index, apart from ignored files.
- A space in an XY code is significant. " M" and "M " are different states. Do not trim leading spaces.
git init -b main >/dev/null
git config user.name "Practice Author"
git config user.email "[email protected]"
git config commit.gpgsign false
git config color.ui false
mkdir -p .disabled-hooks
git config core.hooksPath ".disabled-hooks"
printf 'v1\n' > tracked.txt
git add tracked.txt
git commit -m "Add tracked" >/dev/null
printf 'v2\n' > tracked.txt
printf 'new\n' > extra.txt
echo "short"
git status -s
echo "porcelain"
git status --porcelain=v1
echo "porcelain-b"
git status --porcelain=v1 -b
git add tracked.txt
printf 'v3\n' > tracked.txt
echo "mixed"
git status --porcelain=v1
echo "no-untracked"
git status --porcelain=v1 --untracked-files=no
Expected output
short
M tracked.txt
?? extra.txt
porcelain
M tracked.txt
?? extra.txt
porcelain-b
## main
M tracked.txt
?? extra.txt
mixed
MM tracked.txt
?? extra.txt
no-untracked
MM tracked.txt