git - 将 VSCode 设置为我的 Mac M1 的默认 Git 编辑器

标签 git macos visual-studio-code apple-silicon

最近得到了一个 M1,我正在尝试使用默认的 shell zsh。 我尝试的第一件事是 bash 的常用行:

git config --global core.editor "code -w"

这条线过去曾经像 charm 一样工作,但现在不行了,现在我一遍又一遍地遇到这个错误。

hint: Waiting for your editor to close the file... code -w: code: command not found
error: There was a problem with the editor 'code -w'.

然后我尝试将行 export EDITOR="code -w" 添加到 ~/.zshrc 甚至按照步骤从 shell 命令在 vscode 中安装: 在命令 PATH 中安装“代码”,但显然它在 bash 中安装所有依赖项而不是 zsh。

我到处搜索如何在新的 M1 型号上配置 vsc,但没有找到任何相关内容。

如果有人能阐明如何做到这一点,我们将不胜感激。将 VSC 作为我一般的默认文本编辑器也很好,不仅适用于 Git,适用于所有内容。

最佳答案

如果您使用的是 Visual Studio Code - Insiders,您可以尝试以下 git 命令

git config --global core.editor 'code-insiders --wait'

git config --global core.editor 'code-insiders -w'

如果在运行上述 git 命令后遇到类似的错误,请尝试输入 shell过滤一些 shell 命令,如 Install 'code-insiders' command in PATHUninstall 'code-insiders' command from PATH添加或删除 code-insiders通过输入 ctrl + shift + p 打开命令盘后从 PATH (或 command + shift + p)

顺便说一句,在安装 GitLens 扩展后,将 VSCode 设置为 Git 默认编辑器是一个更好的选择。

关于git - 将 VSCode 设置为我的 Mac M1 的默认 Git 编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65572819/

相关文章:

Git checkout of commit# 将我带到另一个提交#

swift - NSTableView:numberOfRows不被调用

macos - 如何在 XQuartz 中使用 ImageMagick

swift - NSCollectionView - 自定义 View 项未连接或不会选择

visual-studio-code - 每次 VSCode 重启时设置同步提示登录

javascript - VScode 乱码 JSX 格式(美化)

ruby - 如何在代理后面 bundle 安装 git gem?

git bash 问题

git - Intellij Grails和Git

python - VSCode 无法运行 python 并出现此错误 : Error: Session cannot generate requests