如何防止使用寻呼机的git diff? [英] How do I prevent git diff from using a pager?

查看:106
本文介绍了如何防止使用寻呼机的git diff?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有命令行开关默认传递给 git diff 以及其他默认使用 less 寻呼机的命令?

Is there a command line switch to pass to git diff and other commands that use the less pager by default?

我知道我可以管它到猫,但是删除了所有语法高亮。

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-寻呼机 git会告诉它不使用寻呼机。 -F to less会告诉它不是页面,如果输出适合在一个屏幕中。

--no-pager to git will tell it to not use a pager. -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

# tell less not to paginate if less than a page
export LESS='-F -X $LESS'
# ...then git as usual
git diff

这篇关于如何防止使用寻呼机的git diff?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆