brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git status -sb shows a compact status with the branch line

Git
~/tips/tip-git-status-sb-short-branch

git status -sb

Prints the changes as short two-letter codes and adds one line with the branch and its upstream.

The default git status is friendly, but it fills half the screen. The short version fits in a corner.

git status -sb

-s is the short format and -b adds the branch line. The first line looks like ## main...origin/main [ahead 1], with the local branch, its upstream and whether you are ahead or behind. Then one line per file follows.

The two characters before each file name have a meaning. The first column is the staging area and the second is the working tree. So M is modified and staged, M is modified and not yet staged, A is a new staged file and ?? is an untracked file.

## main...origin/main [ahead 1]
 M notes.txt
A  todo.md
?? scratch.txt

It takes a day to learn the codes and then you stop wanting the long form. I like it for a quick check before I commit.

To make it permanent for yourself, the short format can be set as an alias:

git config --global alias.st "status -sb"

The caveat is that the short output has no hints. The long form tells you which command to use to unstage something, and the short form assumes you know. Also, colour is what makes the two columns readable, so check that your terminal shows it.

Further reading: git-status: short format

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link