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版本”-这应该工作:)


其他回答

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

git status

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

这样做:

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版本”-这应该工作:)


对于MAC

首先,类型

git

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

然后:

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

Run:

xcode-select --install

And

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

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

我在Windows 8.1系统下工作的唯一方法是: 添加到系统环境变量(不是用户变量):

c:\Users\USERNAME\AppData\Local\GitHub\ PortableGit_YOURVERSION \ bin \; c: \ \用户名\ AppData \用户本地\ GitHub \ PortableGit_YOURVERSION \ libexec \ git-core \;当地用户c: \ \用户名\ AppData \ \ GitHub \ PortableGit_YOURVERSION \ cmd \

这修复了我的Visual Studio代码上的“看起来git没有安装在您的系统上”错误。

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