git branch ~(END) 在终端上?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51015733/
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
git branch ~(END) on terminal?
提问by Brian Park
To note, I'm on Oh-My-Zsh and git 2.17. Whenever I type in git branch, instead of showing me the branches of my git, it shows something like this:
请注意,我使用的是 Oh-My-Zsh 和 git 2.17。每当我输入 git branch 时,它不会显示我的 git 分支,而是显示如下内容:
~
~
~
~
~
(END)
I can quit this by pressing 'q' on my keyboard, but I'm still confused as to why this is appearing.
我可以通过按键盘上的“q”来退出它,但我仍然不明白为什么会出现这种情况。
回答by Gary Mendonca
Git pipes long output into what's called a pager by default, which can make it easier to view the output if it doesn't fit on a screen. The ~ characters indicate that those lines were not in the original output, but it's showing them so that you can scroll down past the bottom (i.e. the last line of output can go up to the top of the screen).
默认情况下,Git 将长输出传送到所谓的寻呼机中,如果输出不适合屏幕,则可以更轻松地查看输出。~ 字符表示这些行不在原始输出中,但它显示它们以便您可以向下滚动到底部(即输出的最后一行可以上升到屏幕顶部)。
You typically can use the arrow keys to scroll up or down, and can exit by pressing q.
您通常可以使用箭头键向上或向下滚动,并可以按 q 退出。
回答by Fred
You can replace the pager with less
so it doesn't "scroll" outputs less than the height of the terminal.
您可以用 替换寻呼机,less
这样它就不会“滚动”输出小于终端的高度。
git config --global --replace-all core.pager "less -F -X"
git config --global --replace-all core.pager "less -F -X"
I found it from this q. Took a while to find compared to OPs questions, so I figured I'd drop it here in case anyone else has the same issue.
我是从这个 q 中找到的。与 OP 问题相比,花了一段时间才找到,所以我想我会把它放在这里,以防其他人遇到同样的问题。
回答by VonC
Note that:
注意:
git -P branch
would display an empty list, without pager (Git 2.18 for the-P
)git branch | less -F
would do the sameexport LESS=-JMQRiFX
followed by any Git command would avoid the pager (for any result less than a screen)
git -P branch
将显示一个空列表,没有分页器(Git 2.18 for the-P
)git branch | less -F
会做同样的事情export LESS=-JMQRiFX
后跟任何 Git 命令都将避免使用寻呼机(对于小于屏幕的任何结果)