5

Overview:

Just installed the GIT version 2.20.1-64-bit on my Windows 7 platform. Git works well on GIT Bash; but, any git command on Windows CMD or Powershell raises The filename or extension is too long error.

Details:

  • GIT version: 2.20.1-64-bit
  • Platform: Windows 7

Troubleshooting Efforts:

I tried switching longpaths attribute to true based on Filename too long in Git for Windows. I also googled to find other solutions but all recommended the same approach which was updating the git config.

  • The GIT config file updated with git config --system core.longpaths true enter image description here

Issue:

Any Git command via Windows CMD or 3rd party apps like IntelliJ Idea raises the following error:

  • CMD: enter image description here

  • IntelliJ: enter image description here

Please advise me with your genuine solutions.

saeedj
  • 2,179
  • 9
  • 25
  • 38
  • Possible duplicate of [CreateProcess error=206, The filename or extension is too long when running main() method](https://stackoverflow.com/questions/10519558/createprocess-error-206-the-filename-or-extension-is-too-long-when-running-main) – Geno Chen Feb 11 '19 at 01:55
  • Note: this is when running `Git`, not related to a specified repo as your link said, so `core.longpaths` has no usage here. – Geno Chen Feb 11 '19 at 01:57
  • I would like to know if the two lines you totally strike out in `git config --list` hurts. – Geno Chen Feb 11 '19 at 01:58
  • 1
    Besides, I would like to know if `%PATH%` environment variable hurts. – Geno Chen Feb 11 '19 at 01:59
  • Just had a look on the link, my issue is different. I reckon the root cause is `Git has a limit of 4096 characters for a filename, except on Windows when Git is compiled with msys. It uses an older version of the Windows API and there's a limit of 260 characters for a filename.` Commented out lines: `http.sslcainfo= http.sslbackend=openssl` – saeedj Feb 11 '19 at 02:50
  • Git bin directory added to the PATH – saeedj Feb 11 '19 at 02:52

2 Answers2

3

I had the same problem. I then installed it in my user folder and now it works. It seems to be a privilege issue. Git gets installed as admin in C:\Program Files\Git but then can't write to these files because it is run as a user.

Also using the portable version should fix the problem.

schl3ck
  • 119
  • 11
1

Try first to use a simplified PATH and a portable Git (like PortableGit-2.20.1-64-bit.7z.exe) uncompressed anywhere you want.

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

Then check if the issue persists in that CMD session, where you have set said simplified PATH.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250