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: pager.branch false stops git branch from opening a pager

Git
~/tips/tip-git-pager-branch-off

git config --global pager.branch false

Prints short git output straight to the terminal instead of in less.

git branch opens its list in less, and when you quit, the list is gone from the screen. For a short list I’d rather have it printed like any other command.

git config --global pager.branch false

The pager.<command> settings turn the pager on or off per git command. With this one, git branch prints directly to the terminal and the output stays visible above your prompt. The same works for other short commands, such as pager.tag false or pager.stash false.

For a single run, the global --no-pager option does it without changing anything:

git --no-pager log --oneline -5

Another approach is to keep the pager but make it smarter. Setting LESS=FRX in your shell makes less quit by itself when the output fits on one screen and leave it on the screen afterwards. Git sets LESS=FRX itself when the variable is empty, so it only matters if you already set LESS to something else.

Don’t turn the pager off for log or diff unless you really mean it. Without a pager, a git log on a big repository dumps thousands of lines and your terminal scrolls for a while. For those I prefer the FRX route.

Further reading: git-config documentation: pager, git documentation: core.pager

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