Error Codes Wiki

Git for Windows — Filename Too Long Error and Path Length Limit

Warningapplication

Overview

Fix Git for Windows 'Filename too long' error caused by the 260-character Windows path length limit affecting clone, checkout, and pull operations.

Key Details

  • Windows has a default maximum path length of 260 characters (MAX_PATH)
  • Git repositories with deeply nested directories or long filenames exceed this limit
  • Node.js projects with node_modules are especially prone to exceeding the path limit
  • Windows 10 version 1607+ supports long paths but requires explicit enablement
  • Git for Windows has its own setting to handle long paths independently of the system setting

Common Causes

  • Repository containing file paths exceeding 260 characters total
  • node_modules deep nesting creating extremely long paths
  • Git core.longpaths not enabled in Git configuration
  • Windows long path support not enabled in Group Policy or registry

Steps

  1. 1Enable Git long paths: 'git config --global core.longpaths true'
  2. 2Enable Windows long paths: run 'reg add HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f' as administrator
  3. 3Alternatively, enable via Group Policy: Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths
  4. 4Clone repositories closer to the drive root (e.g., C:\repos) to reduce total path length
  5. 5Restart your terminal and computer after enabling long path support

Tags

gitfilename-too-longpath-lengthwindowsnode-modules

More in Application

Frequently Asked Questions

The MAX_PATH constant (260 chars) is a legacy limitation from the Windows API. Modern Windows supports paths up to 32,767 characters but requires explicit opt-in for backward compatibility.