如何防止'git diff'使用寻呼机? [英] How do I prevent 'git diff' from using a pager?
问题描述
默认情况下是否有命令行开关传递给git diff
和其他使用less
寻呼机的命令?
Is there a command line switch to pass to git diff
and other commands that use the less
pager by default?
我知道我可以将其通过管道传递给cat,但这会删除所有语法高亮显示.
I know I can pipe it to cat, but that removes all the syntax highlighting.
我知道我可以通过GITPAGER=cat
(或类似的东西)将全局.gitconfig中的传呼机设置为cat.但有时我想使用寻呼机(取决于差异的大小).
I know I can set the pager in the global .gitconfig to cat by GITPAGER=cat
(or something like that); but I want to have pager sometimes (depending on the size of the diff).
但是,如果有的话,我宁愿使用命令行开关.我找不到手册页中的内容.
But, I would prefer a command line switch if there is one; and I am not able to find one, going through the man pages.
推荐答案
--no-pager
会告诉它不要使用寻呼机.如果将输出-F
放入单个屏幕,则将-F
选项传递给less
将会告诉它不分页.
--no-pager
to Git will tell it to not use a pager. Passing the option -F
to less
will tell it to not page if the output fits in a single screen.
用法:
git --no-pager diff
评论中的其他选项包括:
Other options from the comments include:
# Set an evaporating environment variable to use 'cat' for your pager
GIT_PAGER=cat git diff
# Tells 'less' not to paginate if less than a page
export LESS="-F -X $LESS"
# ...then Git as usual
git diff
这篇关于如何防止'git diff'使用寻呼机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!