我曾经有8个git bash终端同时运行。

目前我只有2个。

我以前没有见过这个错误,我不知道是什么原因造成的。

任何帮助都将不胜感激!

图片附件:


当前回答

为了简化工作(这种问题经常发生),在主目录下创建一个名为fixbash.bat的文件,并粘贴如下:

taskkill /f /IM ssh-agent.exe

当问题发生时,只需打开cmd并键入fixbash.bat来修复问题。

Or

如果你不想创建一个脚本,只需将taskkill命令粘贴到你的cmd。

其他回答

重新安装git,现在工作正常。

在我的例子中,我在Git Bash中运行jupyter-notebook,并在没有关闭notebook的情况下关闭了终端。当我关闭所有运行的git bash终端并试图打开新终端时,这给了我一个错误:

Error: Could not fork child process: There are no available terminals (-1).

解决方案

taskkill /F /IM jupyter-notebook.exe

在那之后,我能够在git bash终端中运行命令。

这里的许多答案都建议他们需要杀死不同的进程,以便能够打开一个新的Git Bash终端。在我的情况下,有多个conhost.exe进程正在运行,我必须在成功打开另一个窗口之前杀死它们。

Perhaps more importantly, is why it happened. I think I know exactly what I did which led to this state. I noticed that when typing git log, if I then resize my Git Bash window, it would hang. (Pressing q would not exit the log and I could no longer type commands.) I ended up closing the window and opening another one. I was doing some testing of this repeatedly to see if I could figure out a solution to the freezing after resizing, and after doing this multiple times (probably around 10 times), I received the error in this question. The results of my testing are:

打开一个新的Git Bash窗口会启动以下过程:

conhost.exe git-bash.exe git.exe mintty.exe

现在,当你输入git log, 4个额外的进程打开:

bash.exe conhost.exe git.exe exe(只有当你的日志无法显示在一个屏幕上时,它才会保持打开状态)

当你关闭Git Bash时,这8个进程通常都消失了。但是,由于一个错误(我认为可能是在less.exe中),当您在查看日志时调整窗口大小时,Git Bash挂起。如果现在关闭窗口,8个进程中只有6个会关闭。less.exe和conhost.exe都保持活动状态。在我的例子中,最终建立了足够多的conhost.exe进程,并导致了导致Git Bash显示错误而无法启动的问题。

也就是说,我试图重复这个问题,但在20多次尝试后放弃了,当我处于问题状态时,这比我必须杀死的conhost进程要多。我怀疑这不是进程号,而是导致错误的一个或多个进程的状态。显然,由于其他答案提到关闭不同的进程,无法正确关闭和对抗Git Bash的“东西”可能会有所不同,这取决于您使用的工具。

注意,我使用的Git版本:2.37.1.windows.1。

我看到的问题在窗口在git bash当我杀死我的git bash控制台不使用退出。我发现从windows任务管理器中杀死ssh-agent.exe任务可以解决这个问题。

请在“任务管理器”窗口中找到ssh-agent进程。 停止或杀死ssh-agent进程后,错误将消失。