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/

其他回答

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

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

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

之后又遇到了同样的问题!

我是怎么修好的?

步骤1:进入vscode中的设置。

步骤2:打开settings.json。

步骤3:你需要找到像“git. git.”在settings.json中的路径"

步骤4:只需在系统中添加安装git的目录路径。

例如:“git”。路径”:“D: / Git / bin / git.exe”

步骤5:重新启动vscode。

希望这能有所帮助。

WINDOWS 10

没有什么能帮我摆脱困境。

问题出现在IntelliJ Idea和VSCode中。

VSCode中的Git选项卡让我Init存储库-它没有检测到工作区中有一个. Git文件夹。

当我在VSCode中从控制台执行git拉时,它要求我通过web浏览器添加凭据。在我登录后,git问题被修复,所有的插件开始工作。 我需要为每个克隆的存储库这样做,即使我在git克隆期间使用了正确的凭据…命令。

Ps.我在Windows上使用CMD通过HTTPS从Gitlab克隆了存储库。VScode使用Powershell -这可能是原因。

现在,您可以配置Visual Studio Code(版本0.10.2,检查旧版本)以使用现有的Git安装。

只需在Visual Studio Code设置(菜单File→Preferences→settings)中添加Git可执行文件的路径,如下所示:

{
    // Is Git enabled
    "git.enabled": true,

    // Path to the Git executable
    "git.path": "C:\\path\\to\\git.exe"

    // Other settings
}

VSCode 1.50(2020年9月)在问题85734中添加了一个有趣的替代方案:

Support multiple values for the git.path setting I use VSCode in three different places; my home computer, my work computer, and as a portable version I carry on a drive when I need to use a machine that doesn't have it. I use an extension to keep my settings synced up between editors, and the only issue I've encountered so far is that the git path doesn't match between any of them. On my home machine I have it installed to C of course, work likes to be funny and install it on A, and for the one on my drive I have a relative path set so that no matter what letter my drive gets, that VSCode can always find git. I already attempted to use an array myself just to see if it'd work: "git.path": ["C:\\Program Files\\Git\\bin\\git.exe", "A:\\Git\\bin\\git.exe", "..\\..\\Git\\bin\\git.exe"], But VSCode reads it as one entire value. What I'd like is for it to recognize it as an array and then try each path in order until it finds Git or runs out of paths.

这是通过PR 85954和提交c334da1解决的。


使用VSCode 1.60+

“git。启用”:真正的 git.path