How do I include --no-pager in a Git alias?

若如初见. 提交于 2019-12-05 00:45:34
Cascabel

You can do that easily by just turning it into a shell command:

hist = "!git --no-pager log ..."

Note: with Git 2.18 (Q2 2018), the alias can use a shorter option for --no-pager:
"git --no-pager cmd" did not have short-and-sweet single letter option. Now it does.

The alias can now be:

hist = "!git -P log ..."

See commit 7213c28 (03 May 2018) by Johannes Sixt (j6t).
(Merged by Junio C Hamano -- gitster -- in commit c9aac55, 23 May 2018)

git: add -P as a short option for --no-pager

It is possible to configure 'less', the pager, to use an alternate screen to show the content, for example, by setting LESS=RS in the environment.
When it is closed in this configuration, it switches back to the original screen, and all content is gone.

It is not uncommon to request that the output remains visible in the terminal. For this, the option --no-pager can be used.
But it is a bit cumbersome to type, even when command completion is available.
Provide a short option, -P, to make the option more easily accessible.

Vivek Karimbil

The --no-pager option gives an unrecognized option error when used after log, but it worked by putting --no-pager before log - "git --no-pager log .... " worked

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