VSCode:在 Windows 上使用 WSL Git 而不是 Git [英] VSCode: use WSL Git instead of Git for Windows

查看:48
本文介绍了VSCode:在 Windows 上使用 WSL Git 而不是 Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 VSCode 中使用 WSL(Windows 上的 Bash)Git 而不是 Windows 版的 Git,以避免多次安装 Git.

I would like to use WSL (Bash on Windows) Git with VSCode instead of Git for Windows to avoid multiple Git installations.

我创建了一个简单的 bat 脚本,通过在 WSL 中重定向 git 命令来模拟 git.exe 功能.它在 CMD 中运行良好,但不适用于 VSCode.另外,WSL 是我在 VSCode 中的默认终端.

I created a simple bat script to emulate git.exe comportment by redirecting git commands in WSL. It works nicely in CMD but not with VSCode. Also, WSL is my default terminal in 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 一起工作的想法?

Any idea to make VSCode working with WSL Git ?

推荐答案

自 VS Code 1.34(2019 年 4 月)以来,已引入远程扩展以开发到 WSL:https://code.visualstudio.com/docs/remote/wsl.

Since VS Code 1.34 (April 2019) a remote extension has been introduced to develop into WSL: https://code.visualstudio.com/docs/remote/wsl.

基本上,VS Code 的服务器实例启动到 WSL,允许您从 Windows 上的客户端实例使用所有 WSL 工具(例如 git).

Basically, a server instance of VS Code is started into WSL, allowing you to use all the WSL tools (e.g. git) from your client instance on Windows.

感谢您指出这一点 @Noornashriq Masnon

这篇关于VSCode:在 Windows 上使用 WSL Git 而不是 Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆