我在用着Git-1.9.0-preview20140217
对于 Windows。据我所知,这个版本应该可以解决文件名太长的问题。但不适合我。
我肯定做错了什么:我做错了git config core.longpaths true
and git add .
进而git commit
。一切顺利。但是当我现在做一个git status
,我得到一个文件列表Filename too long
, 例如:
node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin/node_modules/bin-wrapper/node_modules/download/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js: Filename too long
对我来说重现非常简单:只需创建一个Yeoman https://en.wikipedia.org/wiki/Yeoman_(software)使用 Angular 生成器(“yo Angular”)创建 Web 应用程序并删除node_modules
来自.gitignore
文件。然后重复前面提到的 Git 命令。
我在这里缺少什么?
Git 的文件名限制为 4096 个字符,但在 Windows 上,当 Git 使用 msys 编译时除外。它使用旧版本的 Windows API,并且文件名的字符数限制为 260 个。
据我了解,这是 msys 的限制,而不是 Git 的限制。您可以在这里阅读详细信息:https://github.com/msysgit/git/pull/110 https://github.com/msysgit/git/pull/110
您可以通过使用 Windows 上的另一个 Git 客户端或设置来规避此问题core.longpaths
to true
正如其他答案中所解释的。
git config --system core.longpaths true
Git 是作为脚本和编译代码的组合构建的。通过上述更改,某些脚本可能会失败。这就是 core.longpaths 默认情况下不启用的原因。
Windows 文档位于https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-之后 https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later还有更多信息:
从 Windows 10 版本 1607 开始,MAX_PATH 限制已
从常见的 Win32 文件和目录函数中删除。然而,你
必须选择接受新行为。
注册表项允许您启用或禁用新的长路径
行为。要启用长路径行为,请将注册表项设置为
HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled
(类型:REG_DWORD)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)