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. File > Preferences > setting
2. In search type -> git path
3. Now scroll down a little > you will see "Git:path" section.
4. Click "Edit in settings.json".
5. Now just paste this path there "C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe"

重启VSCode,在VSCode中打开新终端,尝试“git版本”


如果仍然存在问题:

1. Inside terminal click on terminal options (1:Poweshell)
2. Select default shell
3. Select bash

打开新终端,并将终端选项改为2:Bash 再次尝试“git版本”-这应该工作:)


其他回答

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

首先在桌面上安装Git,然后在Visual Studio Code中添加包围的扩展,如图所示。

帮我解决了和你一样的问题。

我在升级到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

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

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

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

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

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