Date posted: 23 Sep 2020, 0 minutes to read

Git clone error: Filename too long on Windows 10

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.

Photo of windy road with car lights in long exposure

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.

Fixing the issue

To fix this you need to do two things:

  1. Tell Windows to support long file paths
  2. Tell Git to support long file paths

Configure Windows for long file paths:

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.

Configure Git for long file paths

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.