You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git Bash已安装但未在Visual Studio Code终端中显示的问题

解决VS Code终端无法使用Git Bash的问题

1. 确认settings.json配置完整性

你提供的配置片段缺少外层的terminal.integrated.profiles.windows键,且未设置默认终端,完整配置应如下:

{
  "terminal.integrated.profiles.windows": {
    "Git Bash": {
      "path": "D:\\Program Files\\Git\\bin\\bash.exe",
      "icon": "terminal-bash"
    },
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    }
  },
  "terminal.integrated.defaultProfile.windows": "Git Bash"
}

添加terminal.integrated.defaultProfile.windows确保默认启动Git Bash,配置后重启VS Code。

2. 验证Git Bash路径有效性

手动打开D:\Program Files\Git\bin\bash.exe,如果无法启动:

  • 修复Git安装:打开Git安装程序,选择「Modify」,确保勾选「Add Git to PATH」(推荐选第二个选项:Git from the command line and also from 3rd-party software)。
  • 若修复无效,卸载后重新安装Git。

3. 排查权限问题

右键Visual Studio Code,选择「以管理员身份运行」,再尝试打开Git Bash终端,部分场景下权限限制会导致终端无法加载。

4. 清除VS Code缓存

关闭VS Code后,删除以下缓存目录:

  • %appdata%\Code\Cache
  • %appdata%\Code\CachedData
    重新启动VS Code测试。

5. 查看终端错误日志

打开VS Code的「输出」面板(快捷键Ctrl+Shift+U),在下拉菜单中选择「Terminal」,查看启动Git Bash时的具体错误信息,根据日志定位问题(如路径错误、依赖缺失等)。

6. 尝试替换为git-bash.exe路径

如果bash.exe无法加载,尝试改用Git安装目录下的git-bash.exe:

"Git Bash": {
  "path": "D:\\Program Files\\Git\\git-bash.exe",
  "icon": "terminal-bash"
}

内容的提问来源于stack exchange,提问作者Rahil Əliyev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 07:17:39