如何退出git log或git diff [复制]

本文翻译自:How to exit git log or git diff [duplicate]

This question already has an answer here: 这个问题在这里已有答案:

I'm trying to learn Git with the help of Git Immersion . 我正试着在Git Immersion的帮助下学习Git。 There's one thing that frustrates me whenever I use git log or git diff : 每当我使用git loggit diff时,有一件事让我感到沮丧:

Git日志显示(END)标记

I can't figure out what to do next when I encounter this (END) word. 当我遇到这个(END)单词时,我无法弄清楚下一步该做什么。 I can't type any commands, and I end up closing the current Bash window and open another. 我无法输入任何命令,我最终关闭当前的Bash窗口并打开另一个。 How do I type in the next command that I want to use? 如何输入我想要使用的下一个命令?


#1楼

参考:https://stackoom.com/question/dn9p/如何退出git-log或git-diff-复制


#2楼

Actually, there are three ways to do it, precisely. 实际上,有三种方法可以做到。

Type any of the following 3 commands. 键入以下3个命令中的任何一个。

  1. : q q
  2. : z or z
  3. Ctrl + z Ctrl + z

PS: Sometimes, for someone, one of these options doesn't seem to work and for others it works. PS:有时候,对于某些人来说,这些选项中的一个似乎不起作用,对其他人来说也是如此。


#3楼

I wanted to give some kudos to the comment that mentioned CTRL + Z as an option. 我想对提到CTRL + Z作为选项的评论给予一些赞誉。 At the end of the day, it's going to depend on what system that you have Git installed on and what program is configured to open text files (eg less vs. vim). 在一天结束时,它将取决于您安装Git的系统以及配置哪些程序来打开文本文件(例如,与vim相比较少)。 CTRL + Z works for vim on Windows. CTRL + Z适用于Windows上的vim。

If you're using Git in a Windows environment, there are some quirks. 如果你在Windows环境中使用Git,那就有一些怪癖。 Just helps to know what they are. 只是有助于了解它们是什么。 (ie Notepad vs. Nano, etc.). (即Notepad vs. Nano等)。


#4楼

Add following alias in the .bashrc file 在.bashrc文件中添加以下别名

git --no-pager log --oneline -n 10
  • --no-pager will encounter the (END) word --no-pager会遇到(END)字
  • -n 10 will show only the last 10 commits -n 10将仅显示最近10次提交
  • --oneline will show the commit message, ignore the author, date information --oneline将显示提交消息,忽略作者,日期信息

#5楼

In this case, as snarly suggested, typing q is the intended way to quit git log (as with most other pagers or applications that use pagers). 在这种情况下,正如snarly建议的那样,输入q是退出git log的预期方式(与大多数其他寻呼机或使用寻呼机的应用程序一样)。

However normally, if you just want to abort a command that is currently executing, you can try ctrl+c (doesn't seem to work for git log , however) or ctrl+z (although in bash , ctrl-z will freeze the currently running foreground process, which can then be thawed as a background process with the bg command). 但通常情况下,如果你只是想中止当前正在执行的命令,你可以尝试ctrl + c (但似乎不适用于git log )或者ctrl + z (虽然在bash中ctrl-z会冻结当前正在运行的前台进程,然后可以使用bg命令将其解冻为后台进程)。


#6楼

You're in the less program, which makes the output of git log scrollable. 你在less程序中,这使得git log的输出可以滚动。

Type q to exit this screen. 输入q退出此屏幕。 Type h to get help. 输入h获取帮助。

If you don't want to read the output in a pager and want it to be just printed to the terminal define the environment variable GIT_PAGER to cat or set core.pager to cat (execute git config --global core.pager cat ). 如果您不想在寻呼机中读取输出并希望它只是打印到终端,请将环境变量GIT_PAGER定义为cat或将core.pager设置为cat (执行git config --global core.pager cat )。

发布了0 篇原创文章 · 获赞 51 · 访问量 34万+

猜你喜欢

转载自blog.csdn.net/CHCH998/article/details/105454735