简体   繁体   English

Git Windows命令提示符在Git命令中被卡住(END)

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

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. 我有Git for Windows安装程序(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)”行,然后我就不能发出任何其他的comamnds。

替代文字

At this point all I get are system beeps. 此时我得到的只是系统发出哔哔声。

Any ideas? 有任何想法吗?

Thanks, P. 谢谢,P

Git want to show more than one screen of information to you, to do so it call the standard unix pager program less . Git希望向您显示多个信息屏幕,这样做可以less标准的unix寻呼机程序。 Just type q to return to the prompt when you no longer want to navigate in the output. 只需输入q即可在不再需要在输出中导航时返回提示。

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

If you want to use git efficiently you should learn the basic unix tools. 如果你想有效地使用git,你应该学习基本的unix工具。 Even if git build and run on windows it's pretty much an alien software on the platform. 即使git构建并在Windows上运行,它也几乎是平台上的外来软件。

If you don't want less just replace it with another pager in the configuration. 如果您不想要less只需将其替换为配置中的另一个寻呼机。 If you don't want a pager at all just use cat : 如果您根本不想使用寻呼机,请使用cat

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

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

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-pager to turn off the whatever pager is defined in the config file. 我发现这个git有一个全局选项 --no-pager来关闭配置文件中定义的任何寻呼机。

This global option is on the git command itself, is available for all subcommands and is placed before the subcommand like this: 这个全局选项在git命令本身上,可用于所有子命令,并放在子命令之前,如下所示:

git --no-pager log

Git is using the "pager" called less , which allows you to scroll through large amount of program output easily. Git正在使用名为less的“寻呼机”,它允许您轻松滚动大量的程序输出。 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 for Windows上的默认设置似乎是为了使寻呼机保持运行,即使输出屏幕少于一个

Here is the default setting I had before, which would always show the (END) and wait for you to hit q before returning you to your prompt: 这是我以前的默认设置,它总是显示(END)并等待你在返回提示之前点击q

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

You can change the behavior so that less will only keep running (and take control of the keyboard) when there is more than a screenful of output by changing the option to -F instead of -+F . 您可以通过将选项更改为-F而不是-+F来更改行为,以便less只会继续运行(并控制键盘)。

Fix the pesky pager with 修复讨厌的寻呼机

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

(The -+X option syntax for less is documented to reset the -X option to its "default", although that is not the behavior I observed with -+F since removing the option altogether was equivalent to -F , not -+F .) (对于less的-+X选项语法被记录为将-X选项重置为其“默认”,尽管这不是我观察到的行为-+F因为完全删除选项等同于-F ,而不是-+F 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM