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?


当前回答

Make sure git is enabled (File --> Preferences --> Git Enabled) as other have mentioned. Make sure Gits installed and in the PATH (with the correct location, by default: C:\Program Files\Git\cmd) - PATH on system variables btw Change default terminal, Powershell can be a bit funny, I recommend Git BASH but cmd is fine, this can be done by selecting the terminal dropdown and selecting 'set default shell' then creating a new terminal with the + button. Restarting VS Code, sometimes Reboot if that fails.

希望这对你有所帮助,最后但并非最不重要的是,它是'git'而不是'git' /'gat'。:)

其他回答

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

三年后,我遇到了同样的问题。在用户设置& path环境变量中设置路径没有帮助。我更新了Visual Studio Code,这就解决了问题。

这可能发生在升级macOS之后。试着在终端上运行Git,看看错误信息是否以:

xrun: error: invalid active developer path (/Library/ developer /CommandLineTools)…

如果是这样,修复是运行:

xcode-select——安装

在终点站。更多细节请看这个答案。

在将macOS升级到Monterey后,我遇到了这个问题。

原来xcode已经在我的mac的新更新中被删除了。只是尝试了以下建议的解决方案:

https://stackoverflow.com/a/52522566/11207358

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

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