Sling, Git, Windows and Filename Too Long

Evgeniy Fitsner Software Engineer
2 min read
Sling, Git, Windows and Filename Too Long

The Problem

When cloning certain projects on Windows, you may encounter the following Git error:

1
error: unable to create file contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.publish/impersonate-reverse/org.apache.sling.distribution.packaging.impl.exporter.AgentDistributionPackageExporterFactory-impersonate-reverse.json: Filename too long

By default, Git on Windows enforces a 260-character path limit due to Windows API constraints. Not all Windows applications handle longer file paths properly. This is particularly problematic when cloning projects like Apache Sling, which have deeply nested directory structures.

Solution

Open Windows PowerShell or CMD as administrator and execute:

1
git config --system core.longpaths true

This enables long path support in Git, allowing file paths up to 32,767 characters.

Alternative

If you cannot modify system-wide Git settings, you can also set this per-repository:

1
git config core.longpaths true

Run this command inside the repository directory after initializing it but before cloning or checking out files.

Windows 10 Note

On Windows 10 version 1607 and later, you can also enable long paths system-wide through the Group Policy Editor or Registry, which removes the 260-character limit for all applications, not just Git.

Contents