为什么我必须在“ git log”末尾打“ Q”?


79

考虑:

git log -n 20 --pretty=oneline

我告诉Git我只需要查看最近的20次提交。我讨厌Q打掉END。有没有办法让我不必打Q吗?

Answers:


83

Git会自动为您分页输出,因为日志往往会轻易溢出单个终端窗口大小(您是一种罕见的例外-单行格式和小的提交限制)。如果您不想这样做,请使用:

git --no-pager log -n 20 --pretty=oneline

请注意,这确实意味着您将得到一些丑陋的包装,因为传呼机以前为您关闭了包装(因为您可以使用光标键左右滚动)。


4
@DeckTrout没有任何信息,没有人可以帮助您。如果您可以具体设置,可以尝试询问新问题。这个答案对这里的OP(以及其他很多OP)都有效,因此很明显与您有所不同。
卡斯卡贝尔2013年

1
添加l = !git --no-pager log -n 20 --pretty=oneline.gitconfig创建别名..
saveshodhan

在Windows的Git上,这会将“ commit insert-hash-here”的提交内容从橙色更改为黄色。
Unknow0059

26

您可以通过告诉它使用cat而不是less来“关闭” git分页。此后,在需要分页时将输出通过较少的管道传递,或者在只希望看到顶部时通过头部传递等等。

git config --global core.pager cat

我关闭自动分页功能是因为我经常在emacs中运行git,而git既不需要也不用它玩得少。


我的git日志没有以换行符结尾,因此该日志后面的shell提示与我最早的提交在同一行。尽管如此,还是不​​错的提示,谢谢。
肯尼·拉沙特

13

less-F如果内容适合一个屏幕,则接受参数以自动退出


8

git log -n 20 --pretty=oneline | cat

比该--no-pager选项短一点,但也会删除所有存在的颜色。




0

日志命令的别名,您无需单击q即可使其消失:

git config --global alias.hist '!git --no-pager log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short --max-count=10'
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.