[英]Troubleshooting: How can I get Git to use VS Code when making a commit?
I recently installed Oh My Zsh and VS code.我最近安装了 Oh My Zsh 和 VS 代码。 Whenever I enter git commit
it doesn't open up code, instead it displays the following error message:每当我输入git commit
时,它都不会打开代码,而是显示以下错误消息:
hint: Waiting for your editor to close the file... error: cannot run code: No such file or directory
error: unable to start editor 'code'
Please supply the message using either -m or -F option.
I am able to just run code by entering code
in the terminal.我可以通过在终端中输入code
来运行代码。
Steps taken:采取的步骤:
I've added the following line to my.zshrc我已将以下行添加到 my.zshrc
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
plugins=(... vscode)
I've run this line:我已经运行了这条线:
git config --global core.editor "code --wait"
I've added these lines in my settings.json in Code我在我的 settings.json 中添加了这些行代码
"terminal.external.osxExec": "iTerm.app",
"terminal.explorerKind": "external",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.shell.linux": "/bin/zsh"
}
What am I missing?我错过了什么? Thanks!谢谢!
Based on your output, which is:基于您的 output,即:
error: cannot run code: No such file or directory
code
is not available in your $PATH environment variable. code
在您的 $PATH 环境变量中不可用。 That can be easily solved:这很容易解决:
Shell Command: Install 'code' command in PATH.
键入“代码路径”之类的内容,或者您要执行的确切命令,即: Shell Command: Install 'code' command in PATH.
And done, that should do the trick.完成了,这应该可以解决问题。
Specific to Zsh, my .zshrc
file also has this line:具体到 Zsh,我的.zshrc
文件也有这一行:
export EDITOR="code -w"
But this might not be relevant in the context of Git, it's useful for other binaries that use VSCode as editor.但这可能与 Git 的上下文无关,它对于使用 VSCode 作为编辑器的其他二进制文件很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.