
As developers, we’ve all experienced the frustration of path-related errors in Windows environments. Perhaps you’ve cloned a repository with deeply nested directories, or your project’s file structure has grown organically over time. Suddenly, Git operations fail with cryptic “Filename too long” errors, bringing your workflow to a screeching halt.
This is a common problem in Windows environments, but fortunately, Git provides a straightforward solution: the core.longpaths configuration option. In this article, we’ll explore:
git config --system core.longpaths true command solves this problemLet’s dive in and unlock the full potential of Git on Windows systems.
Windows has historically enforced a maximum path length of 260 characters, a limitation rooted in the legacy of the Windows API. This constraint comes from the MAX_PATH definition in the Windows header files:
#define MAX_PATH 260
This limitation includes:
While 260 characters might seem sufficient for most use cases, modern development environments with nested package structures, descriptive folder names, and deep directory hierarchies can quickly exceed this limit.
Git was originally developed for Unix-like systems, which have much higher path length limits. When working with Git on Windows, the operating system’s path length limitation can cause operations to fail when:
Error messages typically appear like this:
error: unable to create file [long path]: Filename too long
These errors can be particularly frustrating when working with large projects or when collaborating with teams using different operating systems.
The Git configuration command git config --system core.longpaths true tells Git to enable support for long file paths on Windows systems. Let’s break down each component:
git config: The base command for modifying Git configuration--system: Applies the configuration at the system level (for all users on the machine)core.longpaths: The specific configuration option for path length handlingtrue: Enables support for long pathsWhen this configuration is set, Git bypasses the default Windows API path length limitation by using the extended-length path prefix \\?\ internally, which allows paths up to approximately 32,767 characters.
There are three levels at which you can configure Git:
| Level | Command | Affects | Configuration File |
|---|---|---|---|
| System | --system | All users, all repositories | C:\Program Files\Git\etc\gitconfig |
| Global | --global | Current user, all repositories | ~/.gitconfig |
| Local | --local | Current repository only | .git/config |
Using --system applies the configuration to all users and all repositories on the machine, making it ideal for shared development environments or when you want to set this configuration once and forget about it.
Open Command Prompt or PowerShell as Administrator
Right-click on Command Prompt or PowerShell and select “Run as administrator”.
Run the Git Configuration Command
Enter the following command:
git config --system core.longpaths true
Verify the Configuration
To confirm the configuration was applied correctly, run:
git config --system --get core.longpaths
The output should be true.
Test with a Repository
If you previously encountered path length issues with a specific repository, try the Git operation again to confirm the problem is resolved.
If you don’t have administrative privileges or prefer not to make system-wide changes, you can apply the configuration at different levels:
Global configuration (affects all your repositories):
git config --global core.longpaths true
Repository-specific configuration (affects only the current repository):
git config core.longpaths true
If you receive an “Access denied” error when running the command, ensure you’re using Command Prompt or PowerShell with administrative privileges.
If you continue to experience path length issues after applying the configuration:
Verify Windows Long Path Support Is Enabled
Windows 10 (version 1607 and later) and Windows 11 have a Group Policy setting that needs to be enabled:
Win + R, type gpedit.msc, and press EnterCheck Git Version
Ensure you’re using Git version 2.8.0 or later, which introduced the core.longpaths option:
git --version
Consider Path Structure Optimization
If possible, reorganize your repository structure to reduce path lengths:
Remember that this configuration is specific to Windows. When collaborating with team members using different operating systems:
.gitattributes to help manage line endings and other cross-platform issuesAlways document this configuration in your project’s README or contributing guidelines, especially for projects likely to encounter path length issues.
Example README section:
## Windows Development SetupThis repository contains files with long paths. Windows users should run the following command before cloning:```bashgit config --system core.longpaths true
Proactively design your repository structure to minimize path length where possible:
If your CI/CD pipeline runs on Windows servers, ensure the core.longpaths configuration is applied in your build environment.
The git config --system core.longpaths true command is a simple yet powerful solution to a common frustration for Windows developers working with Git. By understanding and implementing this configuration, you can prevent path-related errors and enjoy a smoother development experience, even with complex or deeply nested projects.
While this configuration addresses the immediate symptom, remember that good repository structure design and conscious path management remain best practices for maintainable codebases.
Your insights drive us! For any questions, feedback, or thoughts, feel free to connect:
If you found this guide beneficial, don’t hesitate to share it with your network. Until the next guide, happy coding! 🚀
Quick Links
Legal Stuff





