【问题标题】:How to exit a 'git status' list in a terminal?如何在终端中退出“git status”列表?
【发布时间】:2010-12-14 08:43:36
【问题描述】:

我是 Git 和终端的新手。如何退出由git status 命令生成的列表模式?

【问题讨论】:

    标签: git command-line terminal


    【解决方案1】:

    在 Linux 终端中

    git diff 输入后

     :q 
    

    您可以退出显示跨页面更改的屏幕。

    从远程合并项目或从远程提取更新后

    ctrl + x
    

    【讨论】:

      【解决方案2】:

      [试试这个,也看看图片]

      我尝试了其他方法,但没有奏效。我只是把'cd ../' 它起作用了

      代码:

      zsh:找不到命令:Q

      $(virtual) ➜ ML git:(master) 退出

      zsh:找不到命令:退出

      $(virtual) ➜ ML git:(master) quit()

      功能>

      $(虚拟) ➜ ML git:(master) cd ../

      (虚拟)➜最终

      【讨论】:

        【解决方案3】:
        :q
        

        实际上,这是一个less 命令。它使用与vi 相同的命令。

        【讨论】:

        • 如果小于,则不需要冒号 (:)。你在想如果 vi!
        • 如果你得到 E37: No write since last change (add ! to override) 错误,照它说的做并使用:q!
        • :q 是我所需要的,即使终端在 less.exe 中,只是 q 什么也没做。谢谢@RageZ
        • 你救了我的命。
        【解决方案4】:

        如果您面临这个问题?

        有时,在使用 Gitbash 编写代码时,您可能会进入 > 并且您无法摆脱它。
        当我在 Gitbash 中错误地输入 ' 时,它经常发生在我身上(见图)。

        如何在 Mac 中解决这个问题?

        控制 + C

        我没有在 Windows 中检查它。但如果确实如此,请在我的回答中进行编辑。

        【讨论】:

        • 我已经检查过它也适用于 Windows !谢谢
        【解决方案5】:

        请在 git bash 中尝试此步骤,它可能对您有所帮助。

        1. CTRL + C
        2. :qa!

        【讨论】:

          【解决方案6】:

          qSHIFT+q 可以解决问题。这将使您摆脱许多广泛的页面滚动会话,例如 git statusgit show HEADgit diff 等。这不会退出您的窗口或结束您的会话。

          【讨论】:

            【解决方案7】:

            您可以为无法识别--no-pager 标志的命令禁用寻呼机。

            git config --global pager.<command> false
            

            我禁用日志别名并设置要返回的特定数量。

            git config --global pager.log false
            

            【讨论】:

              【解决方案8】:

              Crt + c 适用于 Windows!用户1852392

              【讨论】:

                【解决方案9】:

                如果你在 git bash 上尝试使用 exit;

                我尝试使用 q 或 ctrl + q 但它们在 bash 上不起作用。

                【讨论】:

                  【解决方案10】:

                  在按下退出命令(q 等)之前,请检查当前输入语言:如果不是英语命令可能不起作用。

                  【讨论】:

                    【解决方案11】:

                    exit 为我做了。 我按回车后的结果;

                    my-mac:Car Game mymac$ exit
                    logout
                    Saving session...
                    ...copying shared history...
                    ...saving history...truncating history files...
                        ...completed.
                    [Process completed]
                    

                    【讨论】:

                    • 这与关闭整个窗口相同,问题要求像在 ssh 中一样退出 git 会话
                    【解决方案12】:

                    对于窗户:

                    Ctrl+q 和 c 用于退出运行状态。

                    【讨论】:

                      【解决方案13】:

                      我首选的组合是Gq,它会打印所有差异然后退出。

                      你可以输入h来显示与less交互的帮助命令,它会打印到控制台:

                                         SUMMARY OF LESS COMMANDS
                      
                            Commands marked with * may be preceded by a number, N.
                            Notes in parentheses indicate the behavior if N is given.
                      
                        h  H                 Display this help.
                        q  :q  Q  :Q  ZZ     Exit.
                       ---------------------------------------------------------------------------
                      
                                                 MOVING
                      
                        e  ^E  j  ^N  CR  *  Forward  one line   (or N lines).
                        y  ^Y  k  ^K  ^P  *  Backward one line   (or N lines).
                        f  ^F  ^V  SPACE  *  Forward  one window (or N lines).
                        b  ^B  ESC-v      *  Backward one window (or N lines).
                        z                 *  Forward  one window (and set window to N).
                        w                 *  Backward one window (and set window to N).
                        ESC-SPACE         *  Forward  one window, but don't stop at end-of-file.
                        d  ^D             *  Forward  one half-window (and set half-window to N).
                        u  ^U             *  Backward one half-window (and set half-window to N).
                        ESC-)  RightArrow *  Left  one half screen width (or N positions).
                        ESC-(  LeftArrow  *  Right one half screen width (or N positions).
                        F                    Forward forever; like "tail -f".
                        r  ^R  ^L            Repaint screen.
                        R                    Repaint screen, discarding buffered input.
                              ---------------------------------------------------
                              Default "window" is the screen height.
                              Default "half-window" is half of the screen height.
                       ---------------------------------------------------------------------------
                      
                                                SEARCHING
                      
                        /pattern          *  Search forward for (N-th) matching line.
                        ?pattern          *  Search backward for (N-th) matching line.
                        n                 *  Repeat previous search (for N-th occurrence).
                        N                 *  Repeat previous search in reverse direction.
                        ESC-n             *  Repeat previous search, spanning files.
                        ESC-N             *  Repeat previous search, reverse dir. & spanning files.
                        ESC-u                Undo (toggle) search highlighting.
                              ---------------------------------------------------
                              Search patterns may be modified by one or more of:
                              ^N or !  Search for NON-matching lines.
                              ^E or *  Search multiple files (pass thru END OF FILE).
                              ^F or @  Start search at FIRST file (for /) or last file (for ?).
                              ^K       Highlight matches, but don't move (KEEP position).
                              ^R       Don't use REGULAR EXPRESSIONS.
                       ---------------------------------------------------------------------------
                      
                                                 JUMPING
                      
                        g  <  ESC-<       *  Go to first line in file (or line N).
                        G  >  ESC->       *  Go to last line in file (or line N).
                        p  %              *  Go to beginning of file (or N percent into file).
                        t                 *  Go to the (N-th) next tag.
                        T                 *  Go to the (N-th) previous tag.
                        {  (  [           *  Find close bracket } ) ].
                        }  )  ]           *  Find open bracket { ( [.
                        ESC-^F <c1> <c2>  *  Find close bracket <c2>.
                        ESC-^B <c1> <c2>  *  Find open bracket <c1> 
                              ---------------------------------------------------
                      

                      【讨论】:

                        【解决方案14】:

                        首先你需要在终端设置行结束首选项

                        git config --global core.autocrlf input
                        git config --global core.safecrlf true
                        

                        那么你可以使用:q

                        【讨论】:

                        • Windows 用户注意事项:对我来说,添加这些行导致无法将文件添加到跟踪中(致命:CRLF 将被 README.md 中的 LF 替换)。因此,如果您使用的是 Windows,请添加 git config --global core.autocrlf true,它会完成这项工作。
                        【解决方案15】:

                        键入“q”,它会完成这项工作。

                        当您在终端并遇到类似的困境时,请记住尝试输入“退出”、“退出”以及中止组合键“Ctrl + C”。

                        【讨论】:

                        • 当我运行ps -ax 时,我正在使用“Ctrl + Z”并最终得到大量未终止的 git 进程。不知道q
                        • Ctrl+Z 将任务置于后台,所以这是有道理的。我个人无法让 Ctrl+C 关闭它。 q 有效。
                        • Ctrl+C 和 Ctrl+X 都不起作用,只有 :q 能够替我脱身。
                        • 我对一个要求我输入是或否的问题输入了“是”。我按下了qesc 和许多其他键,但直到我可以跨越CTRL + C 并且它让我摆脱了它!
                        【解决方案16】:

                        我必须在这里猜测,但 git 可能正在将其输出运行到您的 $PAGER 程序中,可能是 lessmore。在任何一种情况下,输入 q 都会让你退出。

                        【讨论】:

                        • git使用的分页器由core.pager配置变量选择(如果已设置),然后是GIT_PAGER环境变量,然后是PAGER环境变量,然后是less作为后备。
                        • 键入q 也有助于退出git diff 命令生成的列表模式。竖起大拇指
                        • git config --global core.pager "less -F -X" 让它按照我想要的方式运行 - 没有用于状态、分支等的寻呼机,而是像 git log 这样的寻呼机
                        猜你喜欢
                        • 2013-04-11
                        • 1970-01-01
                        • 2021-10-25
                        • 2019-01-25
                        • 1970-01-01
                        • 1970-01-01
                        • 2017-04-15
                        • 2020-02-06
                        • 2019-07-20
                        相关资源
                        最近更新 更多