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

  1. 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.
  2. Run the command: git config --system core.longpaths true. This sets the configuration globally for all repositories on the system.
  3. 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.
  4. 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 run git checkout . to refresh the working directory.
  5. Test the fix by navigating into a deeply nested folder (e.g., node_modules with 10+ levels) and running git status. No errors should appear.
  6. If you previously received "Filename too long" errors during git pull, git reset, or git 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 --global instead 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 --edit to 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 1 for 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:

  1. Press Win + R, type gpedit.msc, and press Enter to open the Local Group Policy Editor (available on Windows Pro, Enterprise, or Education editions).
  2. Navigate to Computer Configuration > Administrative Templates > System > Filesystem.
  3. Double-click "Enable Win32 long paths" and set it to "Enabled". Click OK.
  4. If you are on Windows Home edition (which lacks gpedit.msc), open Registry Editor as Administrator (regedit), then navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem.
  5. Find the DWORD value named LongPathsEnabled. If it doesn't exist, right-click the right pane, select New > DWORD (32-bit) Value, and name it LongPathsEnabled.
  6. Set its value to 1 and restart your computer.
  7. After reboot, test again with git status in 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.