当前位置:   article > 正文

【git】git clone 出现 Filename too long_linux 的 git拉取报错 file name too long

linux 的 git拉取报错 file name too long

1. git clone 出现 Filename too long

Windows 默认不支持文件名或目录名长于260个字符的,这个涉及到Windows资源管理器、命令行、GitHub客户端以及很多其它应用。所以Git的Windows客户端默认是禁用长名称支持的。
git clone 时出现以下错误:

$ git clone http://ip:port/xxx/xxxxxx.git
Cloning into 'xxxxxx'...
remote: Enumerating objects: 2036, done.
remote: Counting objects: 100% (2033/2033), done.
remote: Compressing objects: 100% (1300/1300), done.
remote: Total 2036 (delta 449), reused 2021 (delta 446), pack-reused 3
Receiving objects: 100% (2036/2036), 2.94 MiB | 4.70 MiB/s, done.
Resolving deltas: 100% (449/449), done.
fatal: cannot create directory at 'xxxx/xxx/xxxxx/xxxxx/xxxxx/xxxxxx': Filename too long
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

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

解决方案

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

git config --system core.longpaths true
  • 1

在这里插入图片描述
然后就可以去成功git了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/856051
推荐阅读
相关标签
  

闽ICP备14008679号