您的位置:首页 > 其它

如何解决Windows中git “filename too long”错误?

2017-04-21 11:18 1276 查看

问题

Windows 默认不支持文件名或目录名长于260个字符的,这个涉及到Windows资源管理器、命令行、GitHub客户端以及很多其它应用。所以Git的Windows客户端默认是禁用长名称支持的。你可以了解更多有关于Windows的260个字符的限制。

如果你打开文件,看到下面的错误:

14:02:42.8556|WARN|thread: 1|StandardUserErrors|Showing user error Failed to create a new commit.
GitHub.IO.ProcessException: fatal: unable to stat 'plugins/toolongname/example/app/platforms/toolongname/toolongname/build/intermediates/classes/debug/org/toolongname/toolongname/toolongname$toolongname$toolongname.class': Filename too long

正如你所看到的,这个文件名(或路径)是超过260个字符的,Git对文件名限制4096个字符,但是由于Windows版本的Git是使用msys编译的。它使用了旧版本的Windows Api,导致它限制文件名不能超过260个字符。

解决方案

打开Powershell或者cmd.exe(你需要将git添加到环境变量中)并执行下面的命令:

git config --system core.longpaths true

我们正在修改git的配置,你可以在任何可以访问到git命令的地方执行它。



这个修改是立即生效的。你可以继续愉快的玩耍了!!

原文链接: http://ourcodeworld.com/articles/read/109/how-to-solve-filename-too-long-error-in-git-powershell-and-github-application-for-windows

如果有翻译不正确的地方请欢迎指正!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐