为什么我必须在“git log”的末尾点击“Q”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2364978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:07:20  来源:igfitidea点击:

Why do I have to hit 'Q' at the end of 'git log'?

git

提问by Nick Vanderbilt

Consider:

考虑:

git log -n 20 --pretty=oneline

I am telling Git that I need to see only the last 20 commits. I hate to hit Qto get rid of END. Is there a way out so that I don't have to hit Q?

我告诉 Git 我只需要查看最后 20 次提交。我讨厌打Q摆脱END。有没有办法让我不必打Q

回答by Cascabel

Git is automatically paging the output for you, since logs tend to easily overflow a single terminal window size (you're in one of the rare exceptions - a oneline format and a small commit limit). If you don't want this, use:

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

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

Note that this does mean you'll get some ugly wrapping, because the pager was previously turning off wrapping for you (since you could use the cursor keys to scroll left-right).

请注意,这确实意味着您将获得一些难看的换行,因为寻呼机之前为您关闭了换行(因为您可以使用光标键左右滚动)。

回答by Wayne Conrad

You can "turn off" git paging by telling it to use cat instead of less. Thereafter, pipe the output through less when you do want paging, or head if you just want to see the top, etc.

您可以通过告诉它使用 cat 而不是 less 来“关闭” git 分页。此后,当您确实想要分页时,通过 less 管道输出,或者如果您只想查看顶部等,则通过管道输出。

git config --global core.pager cat

I turn off automatic paging because I often run git from within emacs, which neither needs nor plays well with less.

我关闭了自动分页,因为我经常在 emacs 中运行 git,它既不需要也不需要less,也不能很好地发挥作用。

回答by hasen

lessaccepts -Fargument to quit automatically if content fits on one screen

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

回答by Aleksandr Zonov

If you want to use --no-pagerin an alias, set up your alias this way:

如果要--no-pager在别名中使用,请按以下方式设置别名:

hist = !git --no-pager log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short

回答by Debilski

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

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

is a little shorter that the --no-pageroption but will also remove any colours present.

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

回答by Ahmed Kotb

The q is used to close the command line programused to view the logs...

q 用于关闭用于查看日志的命令行程序...

You can use another log viewer, like gitk:

您可以使用另一个日志查看器,例如 gitk:

gitk -n 20