Skip to content

Instantly share code, notes, and snippets.

@tmarwen
Created September 18, 2015 14:12
Show Gist options
  • Save tmarwen/75f29828259efcf473a8 to your computer and use it in GitHub Desktop.
Save tmarwen/75f29828259efcf473a8 to your computer and use it in GitHub Desktop.
Git cannot create a file or directory with a long path - Windows OS

Summary

Problem

Windows does not properly support files and directories longer than 260 characters. This applies to Windows Explorer, cmd.exe and many other applications (including many IDEs as well as bash, perl and tcl that come with Git for Windows).

Opt-In configuration

For this reason, long paths support in Git for Windows is disabled by default.

That being said, long paths support for C-based git commands can be enabled by setting the core.longpaths option to true. Scripted git commands may still fail with this option, so use at your own risk. Example: git config core.longpaths true

Technical background

The root cause of the technical limitation of 260 chars lies deeply within the Windows API. Microsoft's online article Naming Files, Paths, and Namespaces describes the reasons. Because Git was originally written on Linux, there's no such limitation. Thus the problem occurs when the original Git code is compiled on the Windows platform.

Implementation details

See this issue and the current fix implemented here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment