Git Windows 命令提示符在使用 (END) 的 Git 命令期间卡住

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3923596/
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-15 15:24:12  来源:igfitidea点击:

Git Windows Command Prompt gets stuck during Git commands with (END)

windowsgitcommand-linecmdmsysgit

提问by paperclip

I've got Git for Windows setup (msysgit) and it was working fine for the last few days and today I've encountered an odd error.

我有用于 Windows 设置的 Git (msysgit),过去几天它运行良好,今天我遇到了一个奇怪的错误。

When issuing a Git command in the Windows Command Prompt or in the Git Bash that comes bundled with msysgit, I get a strange '(END)' line appear and then I cannot issue any other comamnds.

在 Windows 命令提示符或与 msysgit 捆绑在一起的 Git Bash 中发出 Git 命令时,出现奇怪的“(END)”行,然后我无法发出任何其他命令。

alt text

替代文字

At this point all I get are system beeps.

在这一点上,我得到的只是系统哔哔声。

Any ideas?

有任何想法吗?

Thanks, P.

谢谢,P。

回答by Julien Roncaglia

Git want to show more than one screen of information to you, to do so it call the standard unix pager program less. Just type qto return to the prompt when you no longer want to navigate in the output.

Git 想向你显示不止一个屏幕的信息,为此它调用标准的 unix pager 程序lessq当您不想在输出中导航时,只需键入即可返回提示。

  • jmove one line down
  • kmove one line up
  • <space>move one page down
  • bmove one page up
  • hshow the help
  • j向下移动一行
  • k向上移动一行
  • <space>向下移动一页
  • b向上移动一页
  • h显示帮助

If you want to use git efficiently you should learn the basic unix tools. Even if git build and run on windows it's pretty much an alien software on the platform.

如果你想有效地使用 git,你应该学习基本的 unix 工具。即使 git 在 Windows 上构建和运行,它在平台上也几乎是一个陌生的软件。

If you don't want lessjust replace it with another pager in the configuration. If you don't want a pager at all just use cat:

如果您不想less用配置中的另一个寻呼机替换它。如果您根本不需要寻呼机,只需使用cat

git config --global --add core.pager cat

回答by Skilldrick

Press qto exit the pager(which is lessin git by default).

q退出寻呼机less默认情况下在 git 中)。

回答by David Culp

I first came across this question when I was looking for the same thing; to not have to exit out of the log command. I have since found the answer I like, so even though it is well after the original asking I will add this answer to provide an additional solution that I didn't find quickly in my own search.

当我在寻找同样的东西时,我第一次遇到这个问题;不必退出日志命令。从那以后,我找到了我喜欢的答案,因此即使在最初的询问之后很久,我也会添加此答案以提供我在自己的搜索中没有很快找到的其他解决方案。

Others have stated why the (END)is present -- the results are being piped thru a pager, one that can be configured for a different pager.

其他人已经说明了为什么(END)存在 - 结果通过寻呼机通过管道传送,该寻呼机可以配置为不同的寻呼机。

However, I sometimes don't want it to stop at all; because I've specified other options that do the limiting. I found that for this git has a global option--no-pagerto turn off the whatever pager is defined in the config file.

但是,有时我根本不想让它停下来;因为我已经指定了其他限制选项。我发现对于这个git 有一个全局选项--no-pager来关闭配置文件中定义的任何寻呼机。

This global option is on the gitcommand itself, is available for all subcommands and is placed before the subcommand like this:

此全局选项位于git命令本身上,可用于所有子命令,并放置在子命令之前,如下所示:

git --no-pager log

回答by Colin D Bennett

Git is using the "pager" called less, which allows you to scroll through large amount of program output easily. However, the default settings on Git for Windows seem to be to keep the pager running even when there is less than one screen of output.

Git 正在使用名为 的“分页器” less,它允许您轻松地滚动浏览大量程序输出。但是,Windows 版 Git 的默认设置似乎是即使输出少于一屏也保持寻呼机运行

Here is the default setting I had before, which would always show the (END)and wait for you to hit qbefore returning you to your prompt:

这是我之前的默认设置,它总是显示(END)并等待您点击,q然后再返回您的提示:

$ git config --get core.pager
less -+F

You can change the behavior so that lesswill only keep running (and take control of the keyboard) when there is more than a screenful of output by changing the option to -Finstead of -+F.

您可以更改行为,以便less通过将选项更改为-F而不是-+F.

Fix the pesky pager with

修复讨厌的寻呼机

$ git config --global core.pager "less -F"

(The -+Xoption syntax for less is documented to reset the -Xoption to its "default", although that is not the behavior I observed with -+Fsince removing the option altogether was equivalent to -F, not -+F.)

-+X记录了 less的选项语法以将-X选项重置为其“默认”,尽管这不是我观察到的行为,-+F因为完全删除该选项等效于-F,而不是-+F。)