Git commit命令在Atom编辑器中无法正常工作

时间:2019-10-03 11:20:24

标签: git github atom-editor

当我向git bash输入命令“ $ git commit”时,

$ git commit
hint: Waiting for your editor to close the file... atom --wait: atom: command not found
error: There was a problem with the editor 'atom --wait'.
Please supply the message using either -m or -F option.

此错误由git引发。我已经使用以下命令在git中配置了atom:-

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

4 个答案:

答案 0 :(得分:0)

如果出现此问题,则必须:

1-进入“原子”菜单。

2-选择“安装Shell命令”。

3-重新启动终端

这很神奇:D

答案 1 :(得分:0)

在git bash中执行

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

然后您可以在git bash a中做

git commit

,它将打开Atom并等待。输入一条消息,保存并退出。

答案 2 :(得分:0)

这里有一些工具可以解决这个问题。

检查当前配置:

git config --list

检查状态:

git status

查看以下哪种配置适用于原子文本编辑器:

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

确保在终端中运行“ git commit”后打开的文件中保留一条消息。保存并完全退出编辑器。

答案 3 :(得分:0)

遍历您包含的错误:

hint: Waiting for your editor to close the file...

告诉您 git 已尝试打开您指定的编辑器来编写提交消息。这很正常。下一部分:

atom --wait: atom: command not found

告诉您 git 尝试执行 $ atom --wait,但找不到 atom 命令。这表明 atom 命令要么从未安装过,要么不在您的路径上。 (作为参考,在我的 Mac 上运行 Atom 的可执行文件位于 /usr/local/bin/atom

解决方案取决于您的操作系统。

Mac 解决方案

这与Installing Atom on Mac官方文档中描述的问题完全匹配:

<块引用>

当您第一次打开 Atom 时,它会尝试安装 atomapm 命令以在终端中使用。在某些情况下,Atom 可能无法安装这些命令,因为它需要管理员密码。

因此...

<块引用>

要安装 atomapm 命令,请从 Command Palette 运行“Window: Install Shell Commands”,这将提示您输入管理员密码。

或者,Fizik26's Answer 中给出的步骤将完成相同的事情。

注意:“窗口:安装 Shell 命令”操作似乎只在 Mac 上可用,在 Windows 或 Linux 上不可用。