LinuxCommandLibrary

git-column

Format git output into aligned columns

TLDR

Format stdin as multiple columns

$ ls | git column --mode=[column]
copy

Format stdin as multiple columns with a maximum width of 100
$ ls | git column --mode=column --width=[100]
copy

Format stdin as multiple columns with a maximum padding of 30
$ ls | git column --mode=column --padding=[30]
copy

SYNOPSIS

git column [--mode=<mode>] [--width=<width> | -w<n>] [--indent=<n> | -i<n>] [--nl=<str>] [--padding=<n> | -p<n>] [--raw-mode] [<width> | help]

PARAMETERS

--mode=
    Format mode: column (default, aligned columns), dense (tight packing), nodense (columns without dense logic), raw (no reformatting)

--width=, -w
    Maximum line width in characters; defaults to terminal width or 80

--indent=, -i
    Indentation spaces before first column; default 1

--nl=
    String to append after newlines instead of default LF; default empty

--padding=, -p
    Padding spaces between columns; default 1

--raw-mode
    Respect --raw option from upstream Git commands, bypassing some formatting


    Positional argument for width; 'help' prints usage

DESCRIPTION

git column is a Git plumbing command designed to read lines from standard input and format them into aligned columns for improved readability. It is primarily invoked by higher-level Git porcelain commands such as git branch --column, git tag --column, and git for-each-ref --column, which pipe their output through it to display lists in a columnar layout rather than a single vertical list.

The command automatically detects the terminal width unless overridden, distributing items across columns based on their lengths. It supports multiple formatting modes to suit different output needs, from standard spaced columns to densely packed lists. Customizable indentation, padding between columns, and newline separators allow fine-tuned presentation.

Key use cases include listing branches, tags, or references in a compact, scannable format, especially useful in wide terminals. As a plumbing tool, it expects clean, single-line input items and does not perform any parsing or validation itself. Direct usage is possible by piping data, e.g., echo -e 'a bb ccc' | git column, but it's optimized for Git-internal workflows.

CAVEATS

Plumbing command not meant for direct scripting; assumes short, non-multi-line input items. Output may wrap poorly in narrow terminals. Ignores standard Git options like --git-dir unless specified.

EXAMPLE USAGE

git branch -l --column (lists branches in columns)
printf '%s ' a bb ccc | git column --mode=dense (pipes custom input)

INPUT ASSUMPTIONS

Expects one item per line from stdin. Longest line determines column width. Empty lines or very long items may disrupt layout.

HISTORY

Introduced in Git 1.7.10 (June 2010) as git column to support --column option in listing commands. Modes like dense and nodense added in Git 2.13 (2017). Widely used in modern Git for formatted lists.

SEE ALSO

Copied to clipboard