Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Plumbing Commands

git column command

Reference for git column: arrange lines from standard input in columns or rows with --mode, --width, --padding, --indent and --nl, as Git does for branch lists.

git column takes a list of lines on standard input and prints them as a table: several short items side by side instead of one long vertical list. Git uses the same layout code for git branch, git tag, git status and git clean when column.ui is turned on. The command exposes that code for your own scripts.

Each input line is one cell. The command chooses the number of columns to fit the width you give it (or the terminal width), pads the cells so they line up, and prints the result.

Terminal
git column --mode=column --width=60 < items.txt
git branch --format='%(refname:short)' | git column --mode=row

Try it

Bash Column-first and row-first layouts

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Width, padding and indent

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git column [--command=<name>] [--[raw-]mode=<mode>] [--width=<width>]
           [--indent=<string>] [--nl=<string>] [--padding=<n>]
Name Description
--mode=<mode> Layout settings, comma-separated. One of column, row, plain; plus optionally always, never or auto, and dense or nodense.
--raw-mode=<n> Layout as the numeric flag value used internally. Intended for programs that call git column.
--command=<name> Read the layout from column.<name> in the configuration (for example branch), which falls back to column.ui.
--width=<n> Total width available. Defaults to the terminal width, or 80 if that is unknown.
--indent=<string> Text printed before every line.
--nl=<string> Text printed at the end of every line. The default is a newline.
--padding=<n> Spaces between columns. The default is 1.

Modes: column fills each column top to bottom before moving right (like ls). row fills across first. plain prints one item per line and ignores the width. dense lets each column use its own width, so more fit on a line.

Exit status: 0 on success. An unknown mode word is an error.

Usage notes

  • auto and always. auto makes layout happen only when standard output is a terminal; never disables it; always forces it. In scripts and pipes, set a mode explicitly so the output does not change with the environment.
  • Width is measured in display cells. Wide characters such as CJK text count as two; combining marks count as zero.
  • No sorting. Items appear in input order. Sort first if you want alphabetical columns: ... | sort | git column.
  • Long items. A cell wider than the available width gets its own line.
  • Configuration. column.ui accepts the same words as --mode (for example auto,dense), and per-command keys such as column.branch override it. The commands that use columns are branch, status, tag and clean.
  • Not a table formatter. There are no separators, headers or alignment of numbers. Use column -t or printf for real tables.