【问题标题】:Set Visual Studio Code to be global Git editor on OSX将 Visual Studio Code 设置为 OSX 上的全局 Git 编辑器
【发布时间】:2016-04-17 05:00:37
【问题描述】:
【问题讨论】:
标签:
git
macos
visual-studio-code
【解决方案1】:
这对我有用。
从 VSCode 指挥官安装“代码”(Shift + Command + P)
搜索:
Shell 命令:在 'PATH' 中安装 'code' 命令
安装它。
之后……在终端上运行命令以使用新编辑器配置 git:
$ git config --global core.editor "code --wait"
$ git config --global -e
【解决方案2】:
从 VSCode 指挥官安装“代码”(Shift + Command + P)
然后在你的终端中使用这两行,
$ git config --global core.editor "code --wait"
$ git config --global -e
如果你想查看本地 git 配置,
$ cd /path/to/git/repo/
$ git config -e
【解决方案3】:
目前 VS Code 无法做到这一点,但计划在未来实现。
我们的 VS Code 1.0 版本更新:
这现在是可能的!您需要做的就是使用命令行中新引入的--wait 选项将 Code 配置为 git 编辑器。
【解决方案4】:
在 OS X El Capitan (10.11.4) 下我能够设置整个事情:
- 在您的 OS X 上安装 Visual Code Studio(确保它位于 Applications 文件夹
/Applications)
- 使用以下命令创建一个名为
vscode 的链接,该链接链接到您的 Visual Studio(在 Applications 文件夹内)(确保使用正确的路径)。
** 如果 ~/bin 文件夹不存在,则创建它:
cd ~ && mkdir bin
如果文件夹 ~/bin 存在,只需创建一个链接:
ln -s
/Applications/Visual\Studio\Code.app/Contents/Resources/app/bin/code
~/bin/vscode
- 重新启动终端/shell,您应该能够通过在终端窗口中键入
vscode 打开 Visual Studio Code。
vscode
- Visual Studio 应该会打开。如果没有,你有错误。在 OS X 下将
~/bin/ 添加到您的 PATH 中。遵循此 (How do I add ~/bin to my path?)
- 使用
~/.gitconfig 编辑全局git 配置文件并使用code 名称设置编辑器。就我而言,它看起来像这样:
[核心]
编辑器 = vscode --wait
OR 输入
git config --global core.editor "vscode --wait"
- 保存文件并重新启动终端窗口。而已!。现在您应该可以使用 Visual Studio Code 输入提交描述了!