← Back to Blog

Developers & Code | Published Jul 27, 2026 | Updated Oct 13, 2026 | 6 min read

Long File Paths on Windows: Fix MAX_PATH in Git and Monorepos

By Deepender Yadav

Long File Paths on Windows: Fix MAX_PATH in Git and Monorepos — Edge Drop Guide

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):

  1. 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.
  2. Registry: under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem, set the DWORD value LongPathsEnabled to 1. 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\monorepo saves 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\monorepo makes the repository reachable as M:\. The mapping isn't permanent, so recreate it at sign-in if you rely on it. Microsoft lists disk tools such as chkdsk and format that must not be used on a subst drive.
  • Use relative paths in commands. Run tools from the package folder and pass src\components\Header.tsx instead 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 /d to switch drives too). Git Bash and WSL want forward slashes; how to copy a file path that works in the terminal shows the conversions, including wslpath.

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

Sources

Deepender Yadav
Written by Deepender Yadav · Creator & Developer

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 · LinkedIn

Copy. 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
Find us on CodeHype