如何使用 VS Code 修复 git 提交错误 "Waiting for your editor to close the file..."?
How can I fix git commit error "Waiting for your editor to close the file..." with VS Code?
我正在尝试 git commit
而 Git 给出了这条消息:
hint: Waiting for your editor to close the file...
/c/Users/AGT/AppData/Local/Programs/Microsoft VS Code/bin/code: line
28: /Code.exe: No such file or directory error: There was a problem
with the editor 'code --wait'. Please supply the message using either
-m or -F option.
我正在使用或尝试使用 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"
和后续变体(这些变体在错误消息 "unexpected EOF while looking for matching" 处进行了此更改):
- 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 将 git commit
命令修复 BASH 在 Vs Code 中正常工作?这似乎是路径问题。
更新信息:我用 Sublime 3 测试了 git commit
,它工作正常。
您是否确认可以从执行 git 命令的命令行访问 code
?
你可以运行code --version
顺便说一句。当我执行 where code
时,我得到 C:\Program Files\Microsoft VS Code\bin\code
- 它不再安装在 %App_Data% 文件夹中。 但是,如果你只指定code --wait
而不指定路径,这应该是无关紧要的。
换句话说,这是我要尝试的程序:
- 确认
code --version
在您用于 git
的控制台中工作
git config --global core.editor "code --wait"
- 在您的分支中进行更改,然后
git commit
。 VS Code 是否启动并显示 COMMIT_EDITMSG 文件?
如果你的 vs 代码转到左侧的源代码管理选项卡
然后输入您的评论,按 ctrl 并回车
如果你做 git status 它应该什么都不提交,工作树清理..这意味着它有效
将编辑器的名字放在双引号中对我产生了这个错误。将编辑器的名称放在单引号中,例如:
git config --global core.editor 'vi'
或者,如果您已经在使用单引号,请尝试切换到双引号。
期待您输入关于您正在提交的评论的评论,它应该提交代码。
对于将 Atom 作为 Git 相关内容的默认编辑器的人
当 Atom 是它的默认代码编辑器时,Atom 和 Visual Studio 代码之间存在某种冲突。在 Visual Studio 代码中打开终端并点击 git config --global core.editor "code --wait"
解决了问题。然后 Visual Studio 每次我在控制台中执行某些操作而不会崩溃时,代码都会打开一个新选项卡。
任何文件都可以在任何编辑器中打开。
所以 运行 "ps -ax|grep vim" 来检查哪个文件在哪个编辑器中打开。
然后 运行 kill id-of-editor 。例如"kill 12345"
就这些
我在配置 Atom 时遇到了这个错误。
我在执行命令之前在后台打开应用程序解决了这个问题git commit
您也可以尝试使用 $ git commit -m "Initial commit"
它直接传递消息而不等待编辑器打开
注意:您不能仅添加评论
将 git commit
更改为 git commit -m "Title of your update"
。
看起来这与您的情况下的 VS Code 路径以及设置编辑器的命令 git config --global core.editor "code --wait"
不正确有关。
就我而言,我无法完成合并命令。
在确保正确设置 VS Code 之后真正对我有用的是:
code --version
工作正常。
执行中
代码在哪里
向我展示了代码的安装位置与本地应用程序数据所在的位置不同,后者是 git 正在查找的位置。我还可以告诉我无法真正找到代码,因为在我合并时编辑器没有启动.
终于执行了
git config --global core.editor 'code --wait'
对我有用。并不是像其中一条评论中进一步建议的那样用单引号引起来。
git config --global core.editor /usr/bin/vim
帮我解决了。
也许这对某人有帮助
对我来说,我忘记在重新安装后将vscode添加到路径。
要将文件或文件夹添加到路径,请按照下列步骤操作:
搜索变量 => 环境变量 => 路径 => 编辑 => 将完整路径粘贴到文件或文件夹 或 点击浏览并 select 路径 = > 单击确定并退出。
我正在尝试 git commit
而 Git 给出了这条消息:
hint: Waiting for your editor to close the file... /c/Users/AGT/AppData/Local/Programs/Microsoft VS Code/bin/code: line 28: /Code.exe: No such file or directory error: There was a problem with the editor 'code --wait'. Please supply the message using either -m or -F option.
我正在使用或尝试使用 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"
和后续变体(这些变体在错误消息 "unexpected EOF while looking for matching" 处进行了此更改):- 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 将 git commit
命令修复 BASH 在 Vs Code 中正常工作?这似乎是路径问题。
更新信息:我用 Sublime 3 测试了 git commit
,它工作正常。
您是否确认可以从执行 git 命令的命令行访问 code
?
你可以运行code --version
顺便说一句。当我执行 where code
时,我得到 C:\Program Files\Microsoft VS Code\bin\code
- 它不再安装在 %App_Data% 文件夹中。 但是,如果你只指定code --wait
而不指定路径,这应该是无关紧要的。
换句话说,这是我要尝试的程序:
- 确认
code --version
在您用于git
的控制台中工作
git config --global core.editor "code --wait"
- 在您的分支中进行更改,然后
git commit
。 VS Code 是否启动并显示 COMMIT_EDITMSG 文件?
如果你的 vs 代码转到左侧的源代码管理选项卡
然后输入您的评论,按 ctrl 并回车
如果你做 git status 它应该什么都不提交,工作树清理..这意味着它有效
将编辑器的名字放在双引号中对我产生了这个错误。将编辑器的名称放在单引号中,例如:
git config --global core.editor 'vi'
或者,如果您已经在使用单引号,请尝试切换到双引号。
期待您输入关于您正在提交的评论的评论,它应该提交代码。
对于将 Atom 作为 Git 相关内容的默认编辑器的人
当 Atom 是它的默认代码编辑器时,Atom 和 Visual Studio 代码之间存在某种冲突。在 Visual Studio 代码中打开终端并点击 git config --global core.editor "code --wait"
解决了问题。然后 Visual Studio 每次我在控制台中执行某些操作而不会崩溃时,代码都会打开一个新选项卡。
任何文件都可以在任何编辑器中打开。 所以 运行 "ps -ax|grep vim" 来检查哪个文件在哪个编辑器中打开。 然后 运行 kill id-of-editor 。例如"kill 12345" 就这些
我在配置 Atom 时遇到了这个错误。
我在执行命令之前在后台打开应用程序解决了这个问题git commit
您也可以尝试使用 $ git commit -m "Initial commit"
它直接传递消息而不等待编辑器打开
注意:您不能仅添加评论
将 git commit
更改为 git commit -m "Title of your update"
。
看起来这与您的情况下的 VS Code 路径以及设置编辑器的命令 git config --global core.editor "code --wait"
不正确有关。
就我而言,我无法完成合并命令。
在确保正确设置 VS Code 之后真正对我有用的是:
code --version
工作正常。 执行中 代码在哪里 向我展示了代码的安装位置与本地应用程序数据所在的位置不同,后者是 git 正在查找的位置。我还可以告诉我无法真正找到代码,因为在我合并时编辑器没有启动.
终于执行了
git config --global core.editor 'code --wait'
对我有用。并不是像其中一条评论中进一步建议的那样用单引号引起来。
git config --global core.editor /usr/bin/vim
帮我解决了。
也许这对某人有帮助
对我来说,我忘记在重新安装后将vscode添加到路径。
要将文件或文件夹添加到路径,请按照下列步骤操作:
搜索变量 => 环境变量 => 路径 => 编辑 => 将完整路径粘贴到文件或文件夹 或 点击浏览并 select 路径 = > 单击确定并退出。