Git Bash在VSCode中不显示为终端选项

6

我正在使用Windows 10,尝试设置Git Bash终端,但VSCode无法检测到Git的安装或其他什么问题?

我在查看如何设置时,在终端窗口中选择“选择默认shell”,然后选择Git Bash,但对我来说这不是一个选项。VSCode和Git都已正常安装,所以我不明白为什么会出现这种情况?

我需要重新安装这两个应用程序吗?我宁愿不这样做... 有什么建议吗?

3个回答

4
我建议您将类似以下内容的代码添加到您的VS Code配置文件中(请根据您的系统使用适当的路径)。
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\git-cmd.exe",
"terminal.integrated.shellArgs.windows": [
  "--command=usr/bin/bash.exe",
  "-l",
  "-i"
]

这个问题在 https://code.visualstudio.com/docs/editor/integrated-terminal#_windows 中讨论。

你可能还需要在你的~/.bash_profile中添加类似以下的内容:

## make Backspace key and other things work in VS Code's Terminal emulator
export TERM=xterm

我已经在https://www.ii.com/git-bash-is-my-preferred-windows-shell/上写了更多相关的技术内容。


截至2021年4月,terminal.integrated.shell.windowsterminal.integrated.shellArgs已被弃用(请参见https://code.visualstudio.com/updates/v1_56#_terminal)。 - thdoan

0
你可以首先检查你的%PATH%:当git.exe%PATH%中时,我没有使用VSCode检测Git的任何问题。
如果不行的话,尝试在VSCode用户设置中设置Git: Path(需要输入git.exe的完整路径,包括git.exe本身)。

0

如果有人仍然在苦苦挣扎,请查看这个答案

在我的情况下,VSCode和Bash都安装在D盘上,但由于某种原因,VS无法检测到bash。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接