3
votes

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 not found. install it or configure it using '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!

2
I think that the error you get when you exceed the max PATH length. Try to simplify the PATH using variables. Like here: stackoverflow.com/questions/45778066/…Philippe
I have simplified the path to a minimum but the error remains "error launching git: The filename or extension is too long" Path=c:\Progra~1\Git\usr\bin;c:\Progra~1\Git\bin;C:\App\GitLFS;C:\Progra~1\Git\cmd;C:\Program Files\Git\cmdAbdelkrim

2 Answers

5
votes

Solution: find the Git version that works on my computer

Where is Git on my computer?

I have executed the command where git on Windows Command prompt :

C:\Users\<my-user>where git
c:\Program Files\Git\bin\git.exe
C:\Program Files\Git\cmd\git.exe

I have executed the command where git on 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

Which version of Git runs on my computer?

I have executed the command git --version on C:\Program Files\Git\bin\git.exe :

$ "C:\Program Files\Git\bin\git.exe" --version
error launching git: The filename or extension is too long.

I have executed the command git --version on Git\mingw64\bin\git.exe :

$ "C:\Program Files\Git\mingw64\bin\git.exe" --version
git version 2.20.1.windows.1

First conclusion: 2 versions of Git do not work on my computer

Git Bash has a third version of git installed which works on my computer in this path C:\Program Files\Git\mingw64\bin\git.exe

I have adapted the settings on Visual Studio Code and Git works again!

Visual Studio Code > File > Preferences > Settings > Search Settings - type git.path > Edit in settings.json

{
    "git.path": "C:\\Program Files\\Git\\mingw64\\bin\\git.exe", 
   ...
}

Now, Git works again on Visual Studio Code

0
votes

Your .vscode/settings.json contains "git.path": "c:\Program Files\Git\bin\git.exe" with duplicated backslashes (on image c:\\Program Files\\Git\\bin\\git.exe).

If you go in VSCode terminal with cd command to c:\Program Files\Git\bin\ and run git.exe have the same error?