Git can fail to handle file paths longer than 260 characters on Windows by default. Enabling the long path command allows Git to work with deep directory structures and long filenames without errors. This setting is essential for projects using tools like Node.js, .NET, or Java that generate deeply nested node_modules or build folders. Once enabled, Git will correctly clone, commit, and manage files regardless of path length.
What You'll Need
- A Windows system running Git for Windows (version 2.15 or later)
- Administrative privileges to modify system-wide Git configuration
- A repository with long file paths that are currently causing errors
Step-by-Step
- Open Command Prompt or PowerShell as Administrator. Right-click the app in the Start menu and select "Run as administrator" to ensure you have the required permissions.
- Run the command:
git config --system core.longpaths true. This sets the configuration globally for all repositories on the system. - Verify the setting was applied by running:
git config --system --get core.longpaths. The output should be "true". If it returns nothing, the setting was not applied correctly. - If you are cloning a new repository with long paths, proceed with
git clone [repository-url]. If you are working with an existing repository, navigate to it and rungit checkout .to refresh the working directory. - Test the fix by navigating into a deeply nested folder (e.g.,
node_moduleswith 10+ levels) and runninggit status. No errors should appear. - If you previously received "Filename too long" errors during
git pull,git reset, orgit checkout, repeat those commands now—they should succeed.
Common Mistakes
- Running the command without administrative privileges, which causes the setting to be ignored or rejected
- Using
git config --globalinstead of--system, which does not work on Windows for long paths - Assuming the Windows OS itself supports long paths without enabling the Windows registry setting (this is required separately)
- Believing the Git setting alone is sufficient—Windows must also allow long paths via Group Policy or Registry (see Troubleshooting)
- Forgetting to restart any open file explorers or terminals after applying the change; some apps cache path limits
Tips
- Enable long paths on all development machines in your team to avoid inconsistent behavior across environments
- Use
git config --system --editto manually inspect and edit the system config file if troubleshooting is needed - For enterprise environments, deploy this setting via Group Policy or configuration management tools like SCCM or Ansible
- Combine this setting with enabling Windows long path support (see Troubleshooting) for full compatibility
- Some IDEs like Visual Studio or IntelliJ may still show errors if they use Windows APIs with path limits—restart them after enabling the setting
- Consider using
git clone --depth 1for large repositories with long paths to reduce initial checkout time
Troubleshooting
If git config --system core.longpaths true doesn’t resolve the issue, the problem is likely that Windows itself blocks long paths by default. To fix this:
- Press
Win + R, typegpedit.msc, and press Enter to open the Local Group Policy Editor (available on Windows Pro, Enterprise, or Education editions). - Navigate to
Computer Configuration > Administrative Templates > System > Filesystem. - Double-click "Enable Win32 long paths" and set it to "Enabled". Click OK.
- If you are on Windows Home edition (which lacks gpedit.msc), open Registry Editor as Administrator (
regedit), then navigate toHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem. - Find the DWORD value named
LongPathsEnabled. If it doesn't exist, right-click the right pane, select New > DWORD (32-bit) Value, and name itLongPathsEnabled. - Set its value to
1and restart your computer. - After reboot, test again with
git statusin a deeply nested folder. If it still fails, ensure no antivirus software is blocking long paths—some security tools interfere.
Frequently Asked Questions
Does enabling long paths affect performance?
No. Enabling long paths only removes a limitation on filename length. It does not change how Git reads, writes, or indexes files. Performance remains unchanged.
Can I use this on macOS or Linux?
No. macOS and Linux have no inherent 260-character path limit. The core.longpaths setting is only relevant on Windows systems.
What if I get "fatal: bad config line" after running the command?
This usually means the system Git config file is corrupted. Open it manually at C:\ProgramData\Git\config and fix any malformed lines. If you can't fix it, back up the file and delete it—Git will recreate it with defaults.
Do I need to enable this for every repository?
No. Setting --system applies it globally to all repositories on the machine. You only need to run it once per system.
Why does Git still say "Filename too long" even after enabling the setting?
Most likely, Windows long path support is not enabled at the OS level. Follow the Group Policy or Registry steps above. Also ensure you restarted your terminal and file explorer after making changes.
Can I use this with Git Bash, CMD, and PowerShell?
Yes. Once the system setting is applied and Windows long paths are enabled, all these terminals will support long paths. Ensure you are using Git for Windows version 2.15 or higher.