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终端来运行Git命令,而是从应用程序路径下的cmd终端运行Git命令。

其他回答

对于基于linux的操作系统:由于路径损坏,我遇到了这样的问题,但我能够暂时修复这个问题,我的Git安装立即恢复。

如果您遇到这样的路径问题,请键入下面的命令

export PATH="/usr/bin:/bin:$PATH"

我在升级到macOS v10.15 (Catalina)后遇到了这个问题。

问题解决方法如下:

1.

从终端找到Git的位置:

which git

2.

在设置文件中添加Git的位置和你的位置:

settings.json

"git.path": "/usr/local/bin/git",

根据你的平台,用户设置文件(settings.json)位于这里: Windows % APPDATA % \ \用户\ settings.json代码 macOS $HOME/Library/Application Support/Code/User/settings.json Linux $ HOME / config /代码/ User / settings.json

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

Windows 10操作系统:

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

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