threads / discuss / 60516

Document git status -b --porcelain

Subject: Document git status -b --porcelain

## tl;dr

One message between Nov 14, 2023 and Nov 14, 2023.

replies: 0people: 1as markdown or json

Ondra Medek· Nov 14, 2023, 09:14 UTC · lore
Hi,

I am using "git status -b --porcelain" and parsing output in a code. However, the output is not documented for an empty repository or a missing remote branch. (And maybe a detached head, too).

Doc for Porcelain Format Version 1
https://git-scm.com/docs/git-status#_porcelain_format_version_1
references doc for Short Format
https://git-scm.com/docs/git-status#_short_format
and it says:
> If -b is used the short-format status is preceded by a line
>   ## branchname tracking info

However, when I have a fresh clone or an empty repository, "git status -b --porcelain" results in:

## No commits yet on master...origin/master [gone]

So, it seems to me the format is something like "# [info1 ]branchname...tracking[ info2]" and it should be documented what infos may appear and when. Otherwise it's hard to write robust parsing of such output.

Thanks Ondra Medek

← back to recent threads