Sling, Git, Windows and Filename too long

There is a common error on Windows systems when you are working with GIT – Filename too long:

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

What does it means?

It means that by default GIT on Windows has a 260 characters limit due to system limitations (not all Windows apps are properly working with long file names). This can be critical if you will try for example will try to clone Sling application.

Solution

To remove this limitation we should open Windows Power Shell or CMD as administrator and execute command below:

git config --system core.longpaths true

This command will enable long path support and now we could maintain path up to 32,767 characters. For more information you can read this article.