Visual Studio Code reports "It look like git is not installed on your system." when I try to switch to the git view. I know I have git installed and used by other Git clients. I guess if I reinstall Git following Visual Studio Code's instruction ("install it with Chocolatey or download it from git-scm.com"), it probably can fix the problem, but I don't want to mess up the existing Git clients on my system. Is there a reliable way to configure Visual Studio Code so it can find existing git installation?


当前回答

首先检查Git*是否安装在你的系统中,在cmd /命令提示符中输入命令(在Windows中):

where git

如果你得到这样的输出,

λ where git
C:\cmder\vendor\git-for-windows\cmd\git.exe

然后进入设置→首选项→设置,把下面的代码**放在右边。

 {
    // If git enabled?
    "git.enabled": true,

    // Path to the Git executable
    "git.path": "C:\\cmder\\vendor\\git-for-windows\\cmd\\git.exe"
}

如果您没有安装Git,请从https://git-scm.com/安装Git

**只需添加一个双斜杠(\\),就像上面的代码一样。

其他回答

对我来说有用的是在我的系统中手动添加路径变量。

我遵循了这篇文章中的方法3:

https://appuals.com/fix-git-is-not-recognized-as-an-internal-or-external-command/

我发现在设置中有git: false。Json,并将其更改为true。现在起作用了。

在我的例子中,GIT安装在我的WIndows 10操作系统上,在PATH变量中有一个条目。但是VS CODE 1.52.1仍然无法从终端窗口检测到它,但在CMD控制台中可用。

通过将终端从PowerShell切换到CMD或Shell + VsCode重启解决了这个问题。

运行 它会提示你安装命令行开发工具。安装工具并重新启动VScode。 你会在VScode中再次看到git工作

如果git在操作系统更新后丢失,在我的大苏尔的情况下,只是字面上:brew install git