⚡ TL;DR
Learn how to solve the 'Filename too long' or 'unable to create file' error in Git on Windows. Enable core.longpaths globally or config Git during clone.
Resolving ”Filename too long” Error in Git on Windows
The Git “Filename too long” error on Windows happens because Windows limits paths to 260 characters by default (the MAX_PATH limit) and Git for Windows caps its internal paths similarly. Fix it by running git config --system core.longpaths true from an elevated Git Bash, adding longpaths = true to the project’s .git/config, or cloning with git clone -c core.longpaths=true <repository_url>. Alternatively, enable Windows long-path support via the LongPathsEnabled registry value.

Introduction
If you’ve encountered the frustrating “Filename too long” error while using Git on Windows, fear not! We’ve got some simple solutions to help you navigate around this issue and keep your Git workflow smooth.
Why the Error Happens (Root Cause)
Two separate limits stack up here:
- Windows’
MAX_PATHlimit (260 characters). Win32 APIs historically cap full file paths at 260 characters (drive, folders, filename, and null terminator included). Deeply nested repositories — thinknode_modules, Android SDK layouts, or generated docs — blow past this easily. On Windows 10 version 1607 and later, this limit can be lifted system-wide: set the registry valueHKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabledto1(or via Group Policy: Computer Configuration → Administrative Templates → System → Filesystem → “Enable Win32 long paths”). Applications must be manifested for long-path awareness, though, so this alone doesn’t help every tool. - Git’s own path handling. Even where Windows allows longer paths, Git for Windows has an internal limit for path names it will write. Setting
core.longpaths = truetells Git to use Windows’ extended-length (\\?\) path syntax and remove that cap.
So the two settings address different layers: LongPathsEnabled lifts the Windows limit for the whole system, while core.longpaths specifically tells Git it’s allowed to go long.
Solutions
Let’s dive into three straightforward methods to tackle this problem:
1. Enabling Long Paths Globally
First up, we’ll make a system-wide adjustment to Git’s configuration, ensuring that longer filenames are handled without a hitch.
Steps:
- Update Git: Make sure you’re using the latest version of Git.
- Open Your Project Folder: Head to the directory of the project you’re working on.
- Launch Git Bash as Administrator: Right-click on Git Bash and select “Run as administrator” to gain the necessary permissions.
- Enable Long Paths: Type in the following command:
git config --system core.longpaths trueWith this tweak, future cloning operations should breeze through without any filename-related hiccups.
2. Project-Specific Adjustment
If you’re already knee-deep in a project and facing the filename issue, don’t worry! We can tweak the Git settings for that specific project.
Steps:
- Find Your Project’s Directory: Navigate to the main directory of your project.
- Access the “.git” Folder: Look for and open the “.git” directory within your project’s root.
- Update Configuration: Open the configuration file (.git/config) using a text editor.
- Add a Line: Within the [core] section, add the following line:
longpaths = trueThis adjustment will address the filename problem for this project specifically, ensuring smooth sailing from here on out.
3. Configure During Cloning
Lastly, let’s streamline the process by configuring Git to handle long paths right from the get-go when cloning repositories.
Steps:
- When using the git clone command, simply include the -c option along with the cloning command.
Example:
git clone -c core.longpaths=true <repository_url>By doing this, you’re instructing Git to tackle any long filenames encountered during the cloning process.
Caveats Before You Enable core.longpaths
core.longpaths = true solves Git’s side of the problem, but it can push trouble further down your toolchain:
- Tools that don’t support long paths will still choke. A Git operation may succeed while File Explorer, older versions of Visual Studio, some node/npm scripts, or archive utilities later fail to open or delete those same deep files. The files exist; your other tools just can’t reach them.
- GitHub Desktop and SourceTree have historically shipped with long-path limitations of their own — if a checkout still fails inside a GUI tool, try the command line with
core.longpathsset before assuming the setting didn’t work. - Shareability: repos checked out with long paths may not open correctly on machines (or shared drives) without long-path support.
- Deleting becomes painful: files beyond 260 characters can be hard to remove with Explorer or
rdwithout also enablingLongPathsEnabled.
A healthier long-term fix is usually to shorten the paths inside the repository (shallower folder structures, shorter package names) so you don’t depend on special flags at all. But when you can’t change the repo, the solutions above are the reliable escape hatch.
Conclusion
With these simple tweaks, you can bid farewell to the pesky ”Filename too long” error and get back to focusing on your Git projects without any interruptions. Whether you’re adjusting settings globally, fine-tuning for a specific project, or configuring during cloning, these solutions ensure a seamless Git experience on Windows. Happy coding!
Related Posts
- Essential Git Skills: How to Delete Remote Branches
- Understanding Git Merging: Orthogonal vs Recursive Perspectives
FAQ
Why does Git show “Filename too long” on Windows?
Because Windows limits full file paths to 260 characters by default (the MAX_PATH limit) and Git for Windows applies a similar internal cap. Deeply nested repositories — those containing node_modules, Android SDK layouts, or generated docs — easily exceed the limit, so checkout fails when Git tries to write a path that is too long.
How do I fix the “Filename too long” error in Git?
Run git config —system core.longpaths true from an elevated Git Bash to lift the cap globally, or set it per project by adding longpaths = true to the core section of .git/config. You can also enable it at clone time with git clone -c core.longpaths=true. Any one of these lets Git write paths longer than 260 characters.
What is core.longpaths in Git?
core.longpaths is a Git for Windows configuration setting that removes Git’s internal path-length limit by using Windows extended-length path syntax. It tells Git it may write paths beyond the classic 260-character MAX_PATH limit. It affects Git only — other tools like File Explorer or older IDEs still need Windows’ own LongPathsEnabled setting to reach those files.
Are there any downsides to enabling core.longpaths in Git?
Yes. Files beyond 260 characters become hard to open or delete with File Explorer, some node scripts, and older Visual Studio versions, and GitHub Desktop or SourceTree may still fail due to their own limits. Repos checked out with long paths can also misbehave on machines without long-path support, so shortening repository paths is the healthier long-term fix.

Written by Mihir Pipermitwala
Senior Full Stack Consultant & Mobile Engineering Specialist building user-focused applications in healthcare with Flutter, Dart and React Native. I write about what I actually build and test — every tutorial here comes from real project work.
More about Mihir →