关于git add . 遇到filename too long

解决办法

1. 在 Git 里启用长路径支持(Windows 专用)

git config --system core.longpaths true

⚠️ 需要管理员权限运行终端。之后再 git add


2. 把项目路径放浅一点

不要在 D:\work\super\deep\folder\nested\... 下 clone,直接放在 D:\repo 这种浅目录。这样可以减少几十个字符的路径。


3. 忽略掉不需要的测试文件

如果你根本不需要这些 cbmc/proofs 的测试代码,可以加到 .gitignore 里,或者 clone 的时候加 --depth=1 --filter=blob:none,甚至直接删掉相关目录。


4. 换 Linux 环境(WSL / Docker)

如果路径一定要这么长,最简单的办法就是在 Linux 或 WSL 里操作,因为 ext4 不受 Windows 260 限制。

git.exe clone --progress -v "https://codehub-dg-g.huawei.com/x60102926/CP_WearableCloud_HealthDeveloperService_Operation_manger.git" "C:\Users\x60102926\Desktop\HealthDeveloperService_Operation_manger\CP_WearableCloud_HealthDeveloperService_Operation_manger" Cloning into 'C:\Users\x60102926\Desktop\HealthDeveloperService_Operation_manger\CP_WearableCloud_HealthDeveloperService_Operation_manger'... warning: auto-detection of host provider took too long (>2000ms) warning: see https://aka.ms/gcm/autodetect for more information. warning: auto-detection of host provider took too long (>2000ms) warning: see https://aka.ms/gcm/autodetect for more information. POST git-upload-pack (193 bytes) POST git-upload-pack (220 bytes) remote: Enumerating objects: 2404, done. remote: Counting objects: 100% (2404/2404), done. remote: Compressing objects: 100% (1562/1562), done. remote: Total 2404 (delta 736), reused 2404 (delta 736), pack-reused 0 (from 0) Receiving objects: 100% (2404/2404), 1.29 MiB | 2.06 MiB/s, done. Resolving deltas: 100% (736/736), done. error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/bean/basiccalculation/abnormality/ActivityRecordsPeriodStatisticsAbnormalityRequest.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/bean/basiccalculation/abnormality/HealthRecordsPeriodStatisticsAbnormalityRequest.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/bean/basiccalculation/periodstatistics/ActivityRecordsPeriodStatisticsCalculateReq.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/bean/basiccalculation/periodstatistics/HealthRecordsPeriodStatisticsCalculateReq.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/bean/bo/datadict/tech/healthkit/activityrecord/ActivityRecordFieldConversionWrapperBO.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitDisplayBetaRejectedStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitDisplayVerifyAuditStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitDisplayVerifyPassedStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitDisplayVerifyRejectedStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitDisplayWithoutRangeAuditStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitDisplayWithoutRangePassedStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitDisplayWithoutRangeRejectedStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitUpdateBetaPassedWithRangeStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitUpdateBetaRejectedWithRangeStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitUpdatePassedWithoutRangeStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitUpdateRejectedWithoutRangeStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitUpdateVerifyPassedWithRangeStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/common/web/developerscope/strategy/healthkit/HealthkitUpdateVerifyRejectedWithRangeStrategy.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/daobean/datadict/tech/healthkit/activityrecord/ActivityRecordFieldConversionDaoBean.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/daobean/datadict/tech/healthkit/activityrecord/ActivityRecordFieldConversionWrapperDaoBean.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/daobean/datadict/tech/healthkit/activityrecord/ActivityRecordTechDataTypeDaoBean.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/daobean/datadict/tech/healthkit/activityrecord/DataDictTechActivityRecordDaoBean.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/daobean/datadict/tech/sporthealth/datatype/DataDictTechSportHealthDataTypeDaoBean.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/daobean/datadict/tech/sporthealth/datatype/SportHealthDataTypeDataBizPolicyDaoBean.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/mapper/datadict/tech/healthkit/activityrecord/DataDictTechHealthKitActivityRecordMapper.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/mapper/datadict/tech/healthkit/activityrecord/HealthKitActivityRecordTechDataTypeMapper.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/mapper/datadict/tech/healthkit/healthrecord/DataDictTechHealthKitHealthRecordMapper.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/mapper/datadict/tech/healthkit/healthrecord/HealthKitHealthRecordTechDataTypeMapper.java: Filename too long error: unable to create file HealthKitCommon/src/main/java/com/huawei/healthkit/mapper/datadict/tech/sporthealth/datatype/SportHealthDataTypeDataBizPolicyMapper.java: Filename too long Updating files: 100% (1964/1964), 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 with 'git restore --source=HEAD :/' git did not exit cleanly (exit code 128) (9469 ms @ 2025/9/16 14:31:45)
最新发布
09-17
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值