Always use the pager for git diff

喜你入骨 提交于 2019-11-28 20:54:32

问题


I'm using less as my git pager.

If the git diff output is readable on one page, my git prints the output to the screen. Sometimes I'm too fast with typing Ctrl+D (half page down), which kills my terminal. Is there an option to enable the pager for git diff, even if the output is very small?

Doesn't work:

  • git -p diff
  • git --paginate diff
  • git settings: pager.diff = true

回答1:


This is controlled by the -F (--quit-if-one-screen) option to less.

Git uses the options FRSX for/of less by default, if none are specified by the $LESS or $GIT_PAGER environment variables. To change it, specify the core.pager option and set it to RSX:

git config --global core.pager 'less -+F'

Older versions of Git used to recommend the following in their documentation:

git config --global core.pager 'less -+$LESS -RSX'


来源:https://stackoverflow.com/questions/12352049/always-use-the-pager-for-git-diff

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!