Git: Enable denser git status output with --short or status.short - Adam Johnson (original) (raw)
2023-12-07
This post is an adapted extract from my book Boost Your Git DX, available now.
By default git status
uses “long format”, which lists information explicitly. This format takes quite a lot of words and vertical space to split file status by section:
$ git status On branch main Your branch is up to date with 'origin/main'.
Changes to be committed: renamed: aptosaurus.dino -> apatosaurus.dino new file: brontosaurus.dino
Changes not staged for commit: deleted: godzilla.dino modified: triceratops.dino
Untracked files: stegosaurus.dino
It’s clear, and useful when you’re new to Git, but it does take time to read (or skim) through it.
The -s (--short) option enables “short format”, which lists files one per line with a status column. It’s common to combine -s
with -b
(--branch
) to add branch information, which long format displays by default. For example:
$ git status -sb
main...origin/main
R aptosaurus.dino -> apatosaurus.dino A brontosaurus.dino D godzilla.dino MM triceratops.dino UU utahraptor.dino ?? stegosaurus.dino
Short format uses the same status colours as long format.
The left-hand column uses two characters to show the state of the file. The first character indicates staged changes (those that have been git add
-ed), and the second indicates unstaged changes. So in the above:
- “R ” -
aptosaurus.dino
has been renamed, and that rename has been staged. - “A ” -
brontosaurus.dino
is a newly added file. - “ D” -
godzilla.dino
has been deleted, but the deletion is not staged. - “MM” - some changes in
triceratops.dino
have been staged, and some have not. - “UU” - there are unresolved merge conflicts in
utahraptor.dino
. - “??” -
stegosaurus.dino
is an untracked file.
For a complete description of all the possible symbols, see the documentation. But don’t be afraid to learn short format “on the fly” by comparing it with the long format when you don’t understand.
You might want to use short format through a shell alias that you learn to type “by default”. For example, oh-my-zsh defines the gsb
alias for git status -sb
. But you can also make short mode Git’s default by enabling status.short and status.branch
in your global configuration:
$ git config --global status.short true $ git config --global status.branch true
…and then git status
acts as if -sb
has been passed:
$ git status
main...origin/main
R aptosaurus.dino -> apatosaurus.dino A brontosaurus.dino D godzilla.dino MM triceratops.dino UU utahraptor.dino ?? stegosaurus.dino
Then, to flip back to long format on a one-off basis, use --long
:
$ git status --long On branch main Your branch is up to date with 'origin/main'.
Changes to be committed: renamed: aptosaurus.dino -> apatosaurus.dino new file: brontosaurus.dino ...
🎉 My book Boost Your Git DX was updated on January 28th!
One summary email a week, no spam, I pinky promise.
Related posts:
- Git: How to disable status advice
- Git: Show commits that come after
- Git: Output just the current branch name
Tags: git