[英]Troubleshooting: How can I get Git to use VS Code when making a commit?
我最近安裝了 Oh My Zsh 和 VS 代碼。 每當我輸入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.
我可以通過在終端中輸入code
來運行代碼。
采取的步驟:
我已將以下行添加到 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)
我已經運行了這條線:
git config --global core.editor "code --wait"
我在我的 settings.json 中添加了這些行代碼
"terminal.external.osxExec": "iTerm.app",
"terminal.explorerKind": "external",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.shell.linux": "/bin/zsh"
}
我錯過了什么? 謝謝!
基於您的 output,即:
error: cannot run code: No such file or directory
code
在您的 $PATH 環境變量中不可用。 這很容易解決:
Shell Command: Install 'code' command in PATH.
完成了,這應該可以解決問題。
具體到 Zsh,我的.zshrc
文件也有這一行:
export EDITOR="code -w"
但這可能與 Git 的上下文無關,它對於使用 VSCode 作為編輯器的其他二進制文件很有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.