Today I ran into an issue that I tried to clone a Git repository with large filenames/folder paths in it.
fatal: cannot create directory at 'src/Modules/<long path here>': Filename too long
warning: Clone succeeded, but checkout failed.
The folder path display was only 195 characters long, but adding my root folder with 38 characters got awfully close to the known 260 characters limit in Windows.
To fix this you need to do two things:
You can do this either by updating the local Group Policy Setting through the Editor:
1. Windows Run --> gpedit.msc
2. Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths
Or by using the registry editor:
1. Windows Run --> regedit
2. Path: HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem
Key name: LongPathsEnabled
Value: 1
After updating this setting you either need to Sign Out and back on, or reboot the machine.
Git doesn’t know about the changes in Windows and is installed by default without the LongPath setup we need. Enable it from the command line:
git config --system core.longpaths true
Now you can clone the repository again.