VSCode windows 下终端改为 git bash

在 Windows 平台上将 VSCode 的终端改为 Git Bash 的步骤如下:

  1. 确保 Git Bash 已安装

    如果你尚未安装 Git for Windows,请先下载并安装。安装过程中勾选"Use Git and optional Unix tools from the Command Prompt"选项,这样 Git Bash 会被添加到系统路径中。

    也可以下载二进制免安装版,需要手动把路径添加到系统环境变量里面。

  2. 打开 VSCode 设置

    • 按下快捷键 Ctrl+, , 打开设置界面。
    • 或者在菜单栏中选择 File > Preferences > Settings
  3. 修改默认终端配置

    • 在搜索框中输入 terminal.integrated.profiles.windows
    • 点击"Edit in settings.json"(或在右侧直接编辑 JSON 文件)。
  4. 添加或修改终端配置

    在 JSON 文件中添加或修改以下内容(确保路径与你的 Git Bash 安装路径一致):

    {

    "terminal.integrated.profiles.windows": {

    "Git Bash": {

    "path": "C:\\Program Files\\Git\\bin\\bash.exe",

    "args": [""]

    }

    },

    "terminal.integrated.defaultProfile.windows": "Git Bash"

    }

    • 如果 Git 安装在非默认路径,请将 path 替换为实际的 bash.exe 路径(例如 D:\\Git\\bin\\bash.exe)。
    • args 中的 --login -i 确保 Bash 以交互模式启动并加载配置文件。
  5. 保存并重启终端

    • 保存 settings.json 文件。
    • 关闭并重新打开 VSCode 的终端(快捷键 Ctrl + `),此时终端应显示为 Git Bash。

验证是否成功

在终端中输入 echo $SHELL,如果输出 /usr/bin/bash 或类似路径,说明已切换成功。



随便找个 "Edit in setting.json" 点击进入编辑页面,然后配置如下,注意 bash.exe 的路径要和本机匹配

复制代码
    "terminal.integrated.profiles.windows" : {
        "gitBash": {
          "path": "C:\\Programs\\Git_V2373\\bin\\bash.exe",
        }
    },
    "terminal.integrated.defaultProfile.windows": "gitBash",

配置完成后可以搜索 terminal.integrated.defaultProfile.windows, 看看是否配置成功。

相关推荐
70asunflower18 小时前
VS Code 从 0 到 1 完全教程
vscode
蜗牛 Day Day Up1 天前
vscode运行TypeScript
ide·vscode·typescript
cmpxr_1 天前
【VSCode】在类似Trae的软件上使用VSCode的插件市场
ide·vscode·编辑器
时空无限2 天前
mac 如何用命令行操作 vscode 打开哪个文件夹
ide·vscode·macos
MarsBighead2 天前
VSCode Python 调试故障排查:`justMyCode` 配置项引发的血案
ide·vscode·python
R_.L2 天前
【云服务器】VSCode连接云服务器
服务器·vscode
刺心疯2 天前
VScode集成openClaw使用OpenClaw Node for VS Code插件(右键没有openClaw)
vscode·编辑器
tigerlib2 天前
vscode python环境调试,不能调到环境内部,怎么解决
ide·vscode·python
xiaobobo33302 天前
vscode的if结尾提示插件“If End Marker”实现了if结尾提示功能
vscode·插件·if结尾提示·if end marker
硬汉嵌入式2 天前
Clion 2026.1发布,集成AI,支持导入VSCode项目,支持TCP DAP调试等
vscode·编辑器·clion