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?


当前回答

现在,您可以配置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
}

其他回答

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

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

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

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

对于MAC

首先,类型

git

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

然后:

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

Run:

xcode-select --install

And

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

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

通过安装Git Lens Visual Code扩展,我在MacOS上用m1 pro处理器解决了同样的问题。启用扩展名后显示更改的文件。然后我重新加载VSCode,没有任何变化,但一旦我运行

git status

在终端中,显示所有的文件,并跟踪所有的更改。

更新2020 (Mac)

我经过了这个$h!†再次更新到macOS v10.15 (Catalina),这需要Xcode更新。

要澄清的是,虽然这篇文章是关于Visual Studio代码的,但这个问题是系统范围内的。Git安装受到影响。你可以试着在你的终端、Bash、Z shell (zsh)或其他工具中运行git。现在是,以后也不会了。

这是同样的方法。更新Xcode即可。启动它并同意许可。就是这样。


我在Mac/OS X上打了这个。

症状:

你已经使用Visual Studio Code一段时间了,Git没有任何问题 你安装Xcode(不管什么原因-操作系统更新等) 在安装Xcode后,Visual Studio Code突然“找不到Git,并要求你在设置中安装或设置路径”

快速修复:

运行Xcode(安装后第一次)并同意许可。就是这样。

我是如何偶然发现这个“解决方案”的:

在经历了许多关于检查git的技巧后,例如,哪个git和git——版本,后者实际上提供了以下终端消息的线索:

同意Xcode/iOS许可证需要管理员权限,请运行" sudo xcodebuild -license ",然后重试此命令。

至于为什么Xcode会把它的手放在git上,WAT。