【问题标题】:When I Git commit, cmd.exe not found当我 Git 提交时,找不到 cmd.exe
【发布时间】:2020-06-07 07:37:28
【问题描述】:

对 git 很陌生,所以如果我犯了任何明显的错误,我很抱歉。
当我执行 git commit 时,它会打印以下消息:

hint: Waiting for your editor to close the file... /c/Users/UserName/AppData/Local/atom/bin/../app- 
1.44.0/resources/cli/atom.sh: line 23: cmd.exe: command not found
Aborting commit due to empty commit message.

我假设它与写在 atom.sh 文件中的 cmd.exe 有关,但我不确定,我尝试重新安装 atom 和 git 但没有。我做到了

git config --global code.editor "atom --wait" 

我也试过用它的实际目录路径替换“atom”,然后它说:

Waiting for your editor to close the file...
and says aborted due to empty commit message, then opens atom editor.

对不起,如果这是一个有点令人困惑的问题,我已经坚持了这么久。 谢谢

【问题讨论】:

  • 看起来像 $PATH 问题。您是否正确设置了它的路径,或者它在某个时候是否正常工作?
  • 它从来没有工作,我第一次使用 git commit。我应该将它执行到什么路径,atom.exe 或什么,我应该使用 git config 方法更改它吗?
  • 为什么一个sh文件引用了cmd.exe?您使用的是什么操作系统?
  • @CodeWizard .editor 前没有空格
  • 试试PATH=/c/Windows/System32:$PATH...

标签: git atom-editor commit git-commit


【解决方案1】:

正如我 mentioned here 一样,请确保使用简化但完整的 PATH 重新启动 Atom。

它需要包含 Microsoft Windows 路径。
打开 CMD,然后输入:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

set PATH=%LOCALAPPDATA%\atom\bin;%PATH%

从那个 CMD 窗口启动 Atom。如果你愿意,你可以切换到 git bash。但只有在 CMD 中有正确的 PATH 之后。以前没有。

然后查看错误消息是否仍然存在。


OP Safe Rehman提议in the comments

我试过dan1sts method

export PATH=/c/Windows/System32:$PATH 

当我在 git bash 中输入 atom 时,它终于打开了。

关于 IDE Atom,请查看您的 Git integration

git config --global core.editor "atom --wait"

【讨论】:

  • @dan1st 这么简单!谢谢你。我已经相应地修正了答案。
  • @dan1st 我的回答的重点是先修复 PATH,然后 如果需要,您可以切换到 git bash。键入 bash 会让你到达那里。但有一条正确的路径。
  • 大声笑,你们似乎在这方面很有经验,试试你说的话,非常感谢:)
  • @SafeRehman 您是否将set GH=C:\path\to\git 替换为当前git 的实际路径(您可以通过在新CMD 中输入where git 来查看)?
  • @SafeRehman 您是否通过在刚刚设置 PATH 的 CMD 中键入 bash 来打开 bash?
【解决方案2】:

@dan1sts 方法有效!!!!尝试了这么多方法,谢天谢地,我在这里试着做个总结。

第 1 步:确保已将 PATH 添加到系统变量中。

  1. 从“开始”搜索变量,点击“Edict the system” 环境变量

  2. 点击“环境变量”

  3. 在“系统变量”下,选择“路径”并单击“编辑”

  4. 检查你是否有这两个Path,如果没有,添加它们并点击'OK'

    • 'C:\Program Files\Git\bin;'
    • 'C:\Users\XXX\AppData\Local\atom\bin'(XXX 是你的 windows 用户名)

完成后,重新打开 git bash,输入

which atom

你会看到

'/c/Users/XXX/AppData/Local/atom/bin/atom'

第 2 步:然后你可以简单地输入

export PATH=/c/Windows/System32:$PATH

在 Git Bash 上。

最后输入

atom .

对我有用!!!!!!

【讨论】:

    猜你喜欢
    • 2014-12-01
    • 2012-11-03
    • 2016-04-26
    • 2010-11-20
    • 2017-05-14
    • 2017-11-04
    • 1970-01-01
    • 1970-01-01
    • 2020-12-31
    相关资源
    最近更新 更多