如何使用VS Code修复git commit错误“等待编辑器关闭文件...”?

问题描述 投票:12回答:3

我正在尝试git commit,Git正在传达这样的信息:

提示:等待你的编辑器关闭文件... / c / Users / AGT / AppData / Local / Programs / Microsoft VS Code / bin / code:第28行:/Code.exe:没有这样的文件或目录错误:有是编辑'代码 - 等'的问题。请使用-m或-F选项提供消息。

我正在使用或尝试将VS Code作为默认设置,并且在打开或关闭时我收到了相同的消息。通过VS Code或命令git commit -m "Initial commit"完成的提交工作正常。 我试过更改配置路径:

  • git config --global core.editor "code --wait"
  • git config --global core.editor "'C:\Users\AGT\AppData\Local\Programs\Microsoft VS Code\Code.exe' -n -w"和后面的变体(这些更改时出现错误消息“在寻找匹配时意外的EOF”):
  • C:\ Users \ AGT \ AppData \ Local \ Programs \ Microsoft VS Code \ bin
  • C:\ Users \ AGT \ AppData \ Local \ Programs \ Microsoft VS Code \ bin \ code
  • C:\ Users \ AGT \ AppData \ Local \ Programs \ Microsoft VS Code \ Code.exe

根本没有成功。

git状态是:

    On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   css/app.css
        new file:   index.html
        new file:   js/app.js

如何通过Git BASH将其修复为git commit命令与Vs代码一起使用?这似乎是路径问题。

更新信息:我用Sublime 3测试了git commit,它工作正常。

git visual-studio-code git-commit
3个回答
10
投票

您是否确认可以从执行git命令的命令行访问code

你可以运行code --version

BTW。当我执行where code时,我得到C:\Program Files\Microsoft VS Code\bin\code - 它不再安装在%App_Data%文件夹中。如果你只指定没有路径的code --wait,这应该是无关紧要的。

换句话说,这是我尝试的程序:

  1. 确认code --version在您用于git的控制台中工作
  2. git config --global core.editor "code --wait"
  3. 改变你的分支,然后git commit。 VS Code是否启动并显示COMMIT_EDITMSG文件? enter image description here

6
投票

将编辑器的名称放在双引号中会为我生成此错误。将编辑器的名称放在单引号中,例如:

git config --global core.editor'vi'

或者,如果您已使用单引号,请尝试切换为双引号。


0
投票

如果您的in vs代码转到左侧的源代码管理选项卡

然后输入您的评论,按ctrl并输入

如果你做git状态,它应该说什么都没有提交,工作树清理..这意味着它工作

© www.soinside.com 2019 - 2024. All rights reserved.