I want to pass an option to less, which is used to display the results of git show

Question: Question:

Without any special settings
git show branch_name:filename
When I ran, I used less to see the results

How can I pass the -N option to make this less display the line number?

Answer: Answer:

GIT_PAGER="less -N" git show .

The pager used by git is first referenced by the environment variable $GIT_PAGER , then by the setting core.pager , then by the environment variable $PAGER , and finally by the default pager set at compile time (usually the default pager). less ) is referenced.
See core.pager in man git-config for details.

If you want to change the setting permanently, add the setting with git config --global --add core.pager "less -N" .
If you want to clear this setting, edit .gitconfig .

Scroll to Top