How to solve the GitHub Long-path Error?
Published: 23 November 2023

While dealing with YML files that are created by Sitecore,
I faced one error that said the File name was too long when I tried to push my change to the origin of the branch in GitHub.
The "GitHub Long-path Error" typically occurs when you're trying to work with files or directories in a Git repository, and the file path exceeds the maximum path length allowed by the Windows operating system. This issue is commonly encountered on Windows systems due to Windows' historical limitation on file paths, which is 260 characters.

when Git is compiled with msys. It uses an older version of the Windows API and there's a limit of 260 characters for a filename.
But Git has a limit of 4096 characters for a filename, to enable this we need to add
“longpaths = true” in the config file of our repo’s git configuration file which then allows us to use the character limit of 4096 for the file name.
File location: (Repository name)\.git\config

We need to add this line in the [core] section and save the config file.
Now when you reopen the GitHub error should be gone. We can now successfully commit and push the files into the branch (Origin).
Git should now handle long file paths on Windows without triggering the GitHub Long-path Error. This configuration change allows Git to work with file paths longer than the traditional Windows limit.

Mitesh Patel - Technical Head - ADDACT
Sitecore || XMCloud || OrderCloud Certified
Mitesh, a distinguished Technical Head at Addact/Addxp, is a prominent figure in Sitecore/XMCloud/OrderCloud certified writing. From Sitecore XM Cloud Developer Certification to Sitecore 10 .NET Developer Certification and Sitecore OrderCloud Certification, Mitesh's expertise is unparalleled. Mitesh is not only a skilled Sitecore CMS developer but also a 12+ years experienced software engineer proficient in various technologies such as MVC, ASP.Net, C#, jQuery, and Azure cloud/AWS.