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?


当前回答

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

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

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

其他回答

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

在Visual Studio Code中,打开“用户设置”:Ctrl + P并输入>set。按回车。

这将在左侧打开默认设置,在右侧打开用户设置。

只需要在用户设置中添加git.exe的路径:

"git.path": "C:\\Users\\[WINDOWS_USER]\\AppData\\Local\\Programs\\Git\\bin\\git.exe"

用你的用户名替换[WINDOWS_USER]。

重新启动Visual Studio代码。

OS X更新后,我必须运行xcode-select——install才能让GitLens工作。

以下是对我有效的方法。不要使用Visual Studio Code终端来运行Git命令,而是从应用程序路径下的cmd终端运行Git命令。

首先在桌面上安装Git,然后在Visual Studio Code中添加包围的扩展,如图所示。

帮我解决了和你一样的问题。