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?


当前回答

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

我是怎么修好的?

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

步骤2:打开settings.json。

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

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

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

步骤5:重新启动vscode。

希望这能有所帮助。

其他回答

Windows 10操作系统:

我的问题是我在管理模式下使用PowerShell克隆了存储库。当我不在管理模式下启动PowerShell时,VS Code可以检测到Git回购。

在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代码。

Visual Studio Code只是在PATH中查找git。为了简单起见,许多UI客户端附带了“可移植Git”,并且没有将Git添加到路径中。

如果您将现有的git客户端添加到您的PATH(以便它可以找到git.exe), Visual Studio Code应该启用git源代码控制管理。

对于MAC

首先,类型

git

在终端中,看看你得到了什么错误。

然后:

如果错误与命令行工具有关!

Run:

xcode-select --install

And

我们来看看这个答案,尤其是Mac。对我来说很容易。

https://apple.stackexchange.com/a/254381

首先检查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

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