如何修复git commit错误“正在等待您的编辑器关闭文件...";与VS代码? [英] How can I fix git commit error "Waiting for your editor to close the file..." with VS Code?

查看:3272
本文介绍了如何修复git commit错误“正在等待您的编辑器关闭文件...";与VS代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试git commit,而Git正在给出此消息:

I'm trying just git commit and Git is giving this message:

提示:等待编辑器关闭文件... /c/Users/AGT/AppData/Local/Programs/Microsoft VS Code/bin/code:行 28:/Code.exe:没有这样的文件或目录错误:存在问题 使用编辑器代码--wait".请使用以下任一方式提供消息 -m或-F选项.

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"完成的提交工作正常.
我尝试使用以下方式更改配置路径:

I'm using, or trying it, VS Code as default and I got this same message with it opened or closed. Commits done through VS Code or by command git commit -m "Initial commit" works fine.
I tried change config path with:

  • 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 config --global core.editor "code --wait"
  • git config --global core.editor "'C:\Users\AGT\AppData\Local\Programs\Microsoft VS Code\Code.exe' -n -w" and the followed variants(these with this change at error message "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 BASH将其修复为git commit命令,并且可以在Vs Code中正常工作?似乎是路径问题.

How can I fix that to git commit command through Git BASH works fine with Vs Code? It's seems path issue.

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

Update info: I tested git commit with Sublime 3 and it works fine.

推荐答案

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

Have you confirmed that code is accessible from the command line where you execute git commands?

您可以运行code --version

顺便说一句.当我执行where code时,会得到C:\Program Files\Microsoft VS Code\bin\code-它不再安装在%App_Data%文件夹中. 但是,如果仅指定code --wait而没有路径,则这无关紧要.

BTW. When I execute where code I get C:\Program Files\Microsoft VS Code\bin\code - it's no longer installed in the %App_Data% folder. Howerver, this should be irrelevant if you only specify code --wait without the path.

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

In other words, here is the procedure I would attempt:

  1. 确认code --version在用于git
  2. 的控制台中正常工作
  3. git config --global core.editor "code --wait"
  4. 更改分支中的内容,然后更改git commit. VS Code是否启动并显示COMMIT_EDITMSG文件?
  1. Confirm code --version works in the console you use for git
  2. git config --global core.editor "code --wait"
  3. Change things in you branch and then git commit. Does VS Code start and show COMMIT_EDITMSG file?

这篇关于如何修复git commit错误“正在等待您的编辑器关闭文件...";与VS代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆