【发布时间】:2017-11-10 12:42:21
【问题描述】:
我想将 WSL(Windows 上的 Bash)Git 与 VSCode 一起使用,而不是用于 Windows 的 Git,以避免安装多个 Git。
我创建了一个简单的 bat 脚本,通过在 WSL 中重定向 git 命令来模拟 git.exe 行为。它在 CMD 中运行良好,但不适用于 VSCode。另外,WSL 是我在 VSCode 中的默认终端。
VSCode settings.json:
{
"git.path": "D:\\tools\\git.bat",
"terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\bash.exe"
}
和git.bat:
@echo off
bash -c 'git %*'
任何想法让 VSCode 与 WSL Git 一起工作?
【问题讨论】:
-
对我来说奇怪的是,这种方法适用于 ruby、rubocop 以及我尝试过的所有其他可执行文件。我不明白为什么它不适用于 git。
-
这里是官方解决方案:code.visualstudio.com/docs/remote/wsl>。本质上,您只需要安装Remote Development Extension Pack。我遇到的唯一怪癖是,即使您在 zsh 中执行
code .,它也会让您开始使用 bash。
标签: visual-studio-code windows-subsystem-for-linux