Long File Paths on Windows: Fix MAX_PATH in Git and Monorepos
Most Windows programs still limit a full file path to 260 characters (MAX_PATH), which is why deep monorepos and node_modules folders trigger "path too long" errors and Git's "Filename too long". The fix has three parts: turn on Win32 long paths (the LongPathsEnabled registry value or the Enable Win32 long paths policy), tell Git for Windows to use them with git config --global core.longpaths true, and keep the repository near the root of a drive, such as C:\src\. Long paths only work in programs written to support them, so the short root is the fix that helps everywhere.
Why the limit still bites
Microsoft defines MAX_PATH as 260 characters, counting the drive letter, colon, backslash, every folder name and file name, and a terminating null character. Microsoft's own example of hitting it is cloning a Git repository with long file names into a folder that already has a long name.
A monorepo adds up quickly. C:\Users\alexandra.morgan\OneDrive\Documents\Projects\ is already more than 50 characters before the repository name, and paths like apps\web\dashboard\src\components\settings\notifications\ plus a long file name, or a package nested three levels deep in node_modules, take the rest.
Fix 1: Enable Win32 long paths in Windows
Since Windows 10 version 1607, many Win32 file functions accept paths far beyond 260 characters, but only when both of these are true: long paths are enabled on the PC, and the program declares itself long-path aware in its manifest. Enabling the setting doesn't change programs that haven't opted in.
To enable it, use one of these (both need administrator rights):
- Local Group Policy Editor (on editions that include it): go to Computer Configuration > Administrative Templates > System > Filesystem, open Enable Win32 long paths, and set it to Enabled.
- Registry: under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem, set the DWORD valueLongPathsEnabledto1. Microsoft documents this PowerShell command for an elevated terminal:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
Each program reads the value once and caches it for as long as it runs, so restart open apps, and restart Windows if some still don't see it.
Fix 2: Turn on long paths in Git for Windows
Git for Windows ships with long path support disabled. Enable it for all repositories:
git config --global core.longpaths true
Or for a single repository, run git config core.longpaths true inside it. If a clone fails before the repository exists, pass it on the command line: git clone -c core.longpaths=true <url>.
The Git for Windows FAQ notes the limits of this setting: it applies to Git's built-in C commands, while some scripted Git commands and the Bash, Perl and Tcl tools bundled with Git for Windows can still fail on long paths.
Fix 3: Make the paths shorter
Long-path support depends on every tool in your chain opting in: your editor, test runner, build tools, archive utilities and File Explorer. Shorter paths avoid the question entirely:
- Clone to a short root.
C:\src\monoreposaves dozens of characters compared with a folder inside your user profile or OneDrive. - Map a deep folder to a drive letter.
subst M: C:\src\monorepomakes the repository reachable asM:\. The mapping isn't permanent, so recreate it at sign-in if you rely on it. Microsoft lists disk tools such aschkdskandformatthat must not be used on a subst drive. - Use relative paths in commands. Run tools from the package folder and pass
src\components\Header.tsxinstead of the full path.
Find the paths that are too long
To list files in the current folder tree whose full path is 240 characters or more:
Get-ChildItem -Recurse -File -ErrorAction SilentlyContinue |
Where-Object { $_.FullName.Length -ge 240 } |
Select-Object -ExpandProperty FullName
Copying long paths without retyping them
Long paths are miserable to type, and a single typo sends a command to the wrong place. Copy them instead:
- File Explorer: right-click a file or folder and choose Copy as path. On Windows 11 the shortcut is Ctrl+Shift+C. The path is wrapped in quotes, which is what you want when it contains spaces. How to copy a file path to the clipboard covers every method.
- VS Code: right-click in the Explorer and choose Copy Path for the full path or Copy Relative Path for the path from the workspace root.
- Terminal format: PowerShell and Command Prompt take the quoted Windows path as is (in Command Prompt, use
cd /dto switch drives too). Git Bash and WSL want forward slashes; how to copy a file path that works in the terminal shows the conversions, includingwslpath.
To chain commands in Windows PowerShell 5.1, use ; (or if ($?) { ... } to run the second command only on success). The && operator works in PowerShell 7 and Command Prompt, but not in 5.1:
Set-Location "C:\src\monorepo\apps\web\dashboard"; npm test
Pin the paths you use every day
Most people work in five to ten folders of a big repository at a time: the repository root, the app you're changing, its tests, a shared package. Copying those once and pinning them saves the trip through File Explorer every time.
With Windows clipboard history, copy the path, press Win+V, select See more (the ... button) on the item and choose Pin. Pinned items stay when you restart the PC, while unpinned ones are cleared. How to pin items in Windows clipboard history has the details. Pins have no labels, so similar paths are told apart only by their text; a plain paths.md file with a description beside each path works too.
Edge Drop keeps pinned items in their own section of its screen-edge shelf. Pinned items never count against the history limit and survive restarts, its search box finds a path by any part of its text, and clicking a card pastes it into the terminal you were using. How to pin and unpin items in Edge Drop shows how.
Update the pins when you move to a different part of the repository, and remove any that point at folders you no longer use.
FAQ
Do I need to restart after enabling long paths?
Programs cache the setting when they first use an affected file function, so restart the apps you use. Microsoft notes a full restart may be needed for every process to pick it up.
Why does File Explorer still fail with long paths after I enabled them?
The setting only affects programs that declare long-path support. Microsoft also notes that the shell can't always interpret paths the file system accepts. Shorten the path or use a long-path-aware tool for those files.
Does \\?\ fix the limit?
The \\?\ prefix lets Windows API calls use paths up to about 32,767 characters, but it only works with full paths, not relative ones, and only in programs that pass it through to the API. It's a developer tool rather than an everyday fix.
Related reading
- How to Copy a File Path That Works in the Terminal
- How to Copy a File Path in Windows 11 (Copy as Path)
- How to Pin Items in Windows Clipboard History
- WSL Clipboard: Copy and Paste Between Linux and Windows
Sources
- Maximum Path Length Limitation (Microsoft Learn) — MAX_PATH, the
\\?\prefix, LongPathsEnabled, the Group Policy setting, and the manifest requirement. - Git cannot create a file or directory with a long path (Git for Windows) —
core.longpathsand its limitations. - git-config (Git documentation) —
--globaland per-repository configuration. - subst (Microsoft Learn) — mapping a path to a drive letter and commands not to use on subst drives.
- Using the clipboard (Microsoft Support) — pinning items in clipboard history and what's kept after a restart.
Deepender Yadav created Edge Drop and builds and tests it, from the edge-hover shelf to each release. A B.Tech Computer Science Engineering student, Deepender writes the Edge Drop guides, comparisons and developer posts, and checks product details against the app's source code.
GitHub · LinkedInCopy. Stack. Drop.
Transform your clipboard into an interactive edge shelf. Stack, pin, and drag assets into any app with zero friction.
Download for Windows Get from Microsoft Store
How to Install Guide · First 10 Minutes Guide · Drag & Drop Guide · Edge Drop vs Win+V · Support
Free · Lightweight · Privacy First