background
git拉取代码时出现Filename too long错误
Phenomenon
如下:
$ git checkout .
error: unable to create file boot-starters/permission-access-security-service-boot-starter/src/main/java/cn/gzs***/basic/system/platform/starter/permission/access/resource/fetch/PermissionReso***chBaseController.java: Filename too long
Updated 1 path from the index
solve
设置全局变量global core.longpaths为true
git config --global core.longpaths true
设置后查看
git config --list
如果需要取消
git config --global --unset core.longpaths
explain
When using Git on Windows systems, the length of file paths is usually limited to 260 characters. This means that if the file path exceeds this limit, Git will not handle these files properly. However, by running the "git config --global core.longpaths true" command, you can set the "core.longpaths" configuration option to "true", which tells Git to allow file paths longer than 260 characters.
The "--global" option in this command means to set the configuration option as a global configuration, which means it will apply to all your Git repositories. If you only want to enable long path support in a specific repository, you can omit the "--global" option and run the same command in the specific repository's directory.
When the "core.longpaths" option is enabled, Git will be able to handle long paths, enabling you to use longer file paths on Windows systems. This can be very useful for certain projects or specific file structures. But be aware that enabling long path support may cause some older or incompatible tools to not work properly, as they may not be able to handle file paths longer than 260 characters. Therefore, before enabling long path support, make sure your tools and environment can accommodate this change.