Cloning repository in Windows 10 – Error Filename too long

A few days ago, I had to clone a repository on Windows 10. I’m a huge fan of using Linux for development, but this time I had to use Windows to develop. So I have to clone a repository. Everything works well, but when GitHub was finishing applying the changes I got an error.

Filename too long

The first solution that I found was to activate the long names in git. I did it and cloned the repository again, but it didn’t work. So I kept looking for the error and I found that it was an operative system issue.

The problem

Windows 10 has disabled Long Paths by default. But it is possible to enable that. 

The solution

To resolve this problem, you must do:

First Enable LongPaths in github

In a PowerShell you must execute this command

git config --system core.longpaths true

Second Enable LongPaths in Windows 10

You have to open PowerShell in administrator mode.

Then you must execute the next command.

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

Third Reboot your system 

After these two steps, reboot your system and the long paths will work.

 Official documentation

If you want to see the official documentation, you can read the following links:

https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry

 

Leave a Reply