环境
git 2.18.0
TortoiseGit 2.8.0.0(64bit)
windows10 专业版
背景
由于hadoop2.x和hadoop3.x版本的代码结构有很大不同,在查看有关监控的源码发现不一致,为了对比,checkout出hadoop3.1.0版本的源码到本地报错,报错内容如下:
$ git checkout -f head
error: unable to create file hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-common/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/subapplication/SubApplicationColumnFamily.java: Filename too long
error: unable to create file hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-common/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/subapplication/SubApplicationColumnPrefix.java: Filename too long
解决步骤:
1、修改windows的文件路径限制
window10左下角搜索“regedit”,发现“注册表编辑器”,进入到路径“计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem”中,显示界面的右边双击“LongPathsEnabled”,将“数值数据”从“0”改为“1”,确认退出。
2、windows10右下角“win”右键选择“运行”,进入路径“计算机配置\管理模板\系统\文件系统”,界面右侧将“启用Win32长路径”的状态修改为“已启用”。
3、进入到项目根路径,打开git bash界面,执行命令
git config --global core.longpaths true
回车后生效
注意
1、执行第一步和第二步需要重启电脑后生效
2、如果执行第三步报错:
error: could not lock config file /pathto/file/.gitconfig: No such file or directory
尝试了网上很多方法,无效,删除整个项目文件然后重新clone项目后再执行第三步,不报错误,问题解决。
参考链接:
1、https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file
2、https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows