Visual Studio Code cannot detect installed git AND 'error launching git: The filename or extension is too long.'

Abd*_*rim 3 git git-bash visual-studio-code vscode-settings

I have looked at most of the posts describing the first error on the title : "Visual Studio Code cannot detect installed git".

Nevertheless, I believe that the second error "error launching git: The filename or extension is too long." generates the first one.

Could you help me?

  1. Git works while using "Git Bash"
  2. VS Code indicates that git not found. install it or configure it using 'git.path' 找不到 vscode git。 使用“git.path”安装或配置它
  3. VS Code indicates that VSCODE : no source control providers registered VSCODE : no source control providers registered
  4. The .vscode/settings.json contains "git.path": "c:\Program Files\Git\bin\git.exe" enter image description here
    1. Running on the VSCode Terminal the command Git or Git version generates the same error : error launching git: The filename or extension is too long.
    2. Git works perfectly if using Git bash Git works perfectly if using Git bash

Any idea?

Thank you for the time invested!

Abd*_*rim 5

解决方案:找到适用于我电脑的 Git 版本

我电脑上的 Git 在哪里?

我已经where git在 Windows 命令提示符下执行了命令:

C:\Users\<my-user>where git
c:\Program Files\Git\bin\git.exe
C:\Program Files\Git\cmd\git.exe
Run Code Online (Sandbox Code Playgroud)

我已经where git在 GIT BASH 上执行了命令:

$ where git
C:\Program Files\Git\mingw64\bin\git.exe
C:\Program Files\Git\bin\git.exe
C:\Program Files\Git\cmd\git.exe
Run Code Online (Sandbox Code Playgroud)

我的电脑上运行的是哪个版本的 Git?

我已经执行的命令git --versionC:\Program Files\Git\bin\git.exe

$ "C:\Program Files\Git\bin\git.exe" --version
error launching git: The filename or extension is too long.
Run Code Online (Sandbox Code Playgroud)

我已经执行的命令git --versionGit\mingw64\bin\git.exe

$ "C:\Program Files\Git\mingw64\bin\git.exe" --version
git version 2.20.1.windows.1
Run Code Online (Sandbox Code Playgroud)

第一个结论:2 个版本的 Git 在我的电脑上不起作用

Git Bash 安装了第三个版本的 git,它可以在我的计算机上通过此路径运行 C:\Program Files\Git\mingw64\bin\git.exe

我已经调整了 Visual Studio Code 上的设置,Git 又可以工作了!

Visual Studio Code > 文件 > 首选项 > 设置 > 搜索设置 - 输入 git.path > 在 settings.json 中编辑

{
    "git.path": "C:\\Program Files\\Git\\mingw64\\bin\\git.exe", 
   ...
}
Run Code Online (Sandbox Code Playgroud)

现在,Git 再次在 Visual Studio Code 上工作