The git log
command is what Git calls porcelain. This means it is meant to be used by actual humans, as opposed to other Git commands like git rev-parse
and git for-each-ref
that are mostly or entirely meant for computer programs to run.
Porcelain commands are usually configurable, and often do things like color or paginate their output. This is true for git log
as well. Several of the controls for this are git config
entries:
color.ui = auto
log.decorate = auto
This auto setting, which is the default—you can change it to always
or never
—tells Git: When the command writes its output to a terminal, do it, but when it does not (like when it writes to a pipe as in git branch | grep ...
), don't do it.
The log.decorate
option controls the (master)
decorations. Whether particular text is colored, and if so, with which colors, is controlled by a rather complicated maze of options that merely starts with color.ui
.
Setting color.ui
to always
will break naive scripts that run porcelain commands in pipelines and expect color.ui
to be set to its default auto
. None of Git's own scripts are naive like this, but you may be using your own extensions, or ones obtained from people who didn't think about the issue, so be careful when overriding these defaults.
(By the way, be careful about the =
in settings. These are required inside .git/config
and git -c color.ui=true log
, for instance, but forbidden in git config log.decorate auto
. It's a crazy mishmash of historical artifacts and coding whatever was expedient at the time.)