赞
踩
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 :/'
这个文件名(或路径)是超过260个字符的,Git对文件名限制4096个字符,但是由于Windows版本的Git是使用msys编译的。它使用了旧版本的Windows Api,导致它限制文件名不能超过260个字符。
打开Powershell或者cmd.exe(你需要将git添加到环境变量中)并执行下面的命令:
git config --system core.longpaths true
然后就可以去成功git了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。