António Coelho
António Coelho

Reputation: 21

What is Git's command line diff and log viewer?

When calling git log or git diff in the terminal the result is displayed using some kind of viewer. I know how to navigate, quit and search for keywords but wanted to have some background on what I am actually doing. What is this viewer's name and where is this viewer documented?

I know the editor goes to my default text editor but this "viewer" seems to be something else. I have been looking for it for a while but I am not sure I am searching using the correct keywords.

Upvotes: 2

Views: 208

Answers (3)

gzh
gzh

Reputation: 3596

git use less for default viewer, you can look manpage of less to find how to search in it.

Upvotes: 1

larsgrefer
larsgrefer

Reputation: 2853

The default viewer is less:

core.pager

Text viewer for use by Git commands (e.g., less). The value is meant to be interpreted by the shell. The order of preference is the $GIT_PAGER environment variable, then core.pager configuration, then $PAGER, and then the default chosen at compile time (usually less).

When the LESS environment variable is unset, Git sets it to FRX (if LESS environment variable is set, Git does not change it at all). If you want to selectively override Git’s default setting for LESS, you can set core.pager to e.g. less -S. This will be passed to the shell by Git, which will translate the final command to LESS=FRX less -S. The environment does not set the S option but the command line does, instructing less to truncate long lines. Similarly, setting core.pager to less -+F will deactivate the F option specified by the environment from the command-line, deactivating the "quit if one screen" behavior of less. One can specifically activate some flags for particular commands: for example, setting pager.blame to less -S enables line truncation only for git blame.

Likewise, when the LV environment variable is unset, Git sets it to -c. You can override this setting by exporting LV with another value or setting core.pager to lv +c.

https://git-scm.com/docs/git-config

Upvotes: 1

Mureinik
Mureinik

Reputation: 311273

The default viewer for git is less. You can change it to something else (e.g., more) by setting the code.pager config value. E.g.:

$ git config --global core.pager more

You can find out more in the Git Configuration documentation.

Upvotes: 3

Related Questions