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: column.ui auto prints long git lists in columns

Git
~/tips/tip-git-column-ui-branch-list

git config --global column.ui auto

Prints git branch and similar lists in columns when the output goes to a terminal.

A repository with forty branches turns git branch into a very tall list. Git can print it in columns, the way ls does, and one setting makes that the default.

git config --global column.ui auto

The values are always, never and auto, and never is the default. With auto git uses columns only when the output goes to a terminal, so a script that reads the output of git branch still gets one name per line.

Layout can be added to the same value. The manual lists column (fill columns before rows, the default), row (rows before columns) and plain (one column), plus dense for columns of unequal width that use less space:

git config --global column.ui "auto,row,dense"

If you only want it once, git branch --column does that without touching the config, and --no-column turns it off again.

Caveat: columns make long branch names harder to read, and a name that is cut off or wrapped is easy to copy wrongly. When I want to pick a branch for a command, I would still use a one-per-line view. This setting is for browsing.

Further reading: git config, column.ui (Git documentation)

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

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