git bash下的Filename too long

描述

从github克隆一个项目下发出现了错误:

cglong@cglong MINGW64 /c/Tools/workspace/idea/open
$ git clone git@github.com:imarkofu/shenyu.git
Cloning into 'shenyu'...
Warning: Permanently added the RSA host key for IP address '52.192.72.89' to the list of known hosts.
remote: Enumerating objects: 53479, done.
remote: Counting objects: 100% (15170/15170), done.
remote: Compressing objects: 100% (4534/4534), done.
remote: Total 53479 (delta 4593), reused 14765 (delta 4365), pack-reused 38309
Receiving objects: 100% (53479/53479), 20.72 MiB | 128.00 KiB/s, done.
Resolving deltas: 100% (17773/17773), done.
error: unable to create file shenyu-spring-boot-starter/shenyu-spring-boot-starter-sync-data-center/shenyu-spring-boot-starter-sync-data-websocket/src/main/java/org/apache/shenyu/springboot/starter/sync/data/websocket/WebsocketSyncDataConfiguration.java: Filename too long
error: unable to create file shenyu-spring-boot-starter/shenyu-spring-boot-starter-sync-data-center/shenyu-spring-boot-starter-sync-data-websocket/src/test/java/org/apache/shenyu/springboot/starter/sync/data/websocket/WebsocketSyncDataConfigurationTest.java: Filename too long
Checking out files: 100% (1439/1439), done.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'


git可以创建4096长度的路径,然而Windows 默认不支持文件名或目录名长于260个字符,所以Git的Windows客户端默认是禁用长名称支持的。

解决

git config --global core.longpaths true