git push error unable to create temporary sha1 filename

本文介绍了遇到Git推送代码失败时的一种罕见错误“unable to create temporary sha1 filename!”的排查与解决过程,包括检查权限、确认磁盘空间及修复文件系统等问题。

问题描述

今天push代码  发现git报错如下

unable to create temporary sha1 filename!

网上找了下  发现几乎没有这个问题 有几个相似的问题 有的说版本库xxx.git权限不对  登陆到服务器上

排查过程


[xxx@xxx xxx]# ll | grep xxx.git

drwxr-xr-x  7 git git 4096 11月  1 19:00 xxx.git

发现权限没有问题  git用户  755权限 没有问题   然后我就觉得这不是一个简单的问题 


请系好安全带  老司机要转弯了  非正常问题要用非正常思维来考虑  果然

[xxx@xxx xxx]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       20G   19G  23M  100% /
tmpfs           1.9G     0  1.9G   0% /dev/shm 

磁盘满了 shit!


常见情况及解决办法


感谢mingdh258同学的提醒   断电造成的磁盘锁定也会造成这种问题

在这里总结一下    git类似unable to write/create的错误 基本上都是git服务器的写入问题 目前已知的情况如下

1.服务器磁盘写满 导致无法写入     解决办法 清理磁盘分区

2.系统没有正常关机导致虚拟磁盘出现文件系统错误   可能只是一个分区也节能整个文件系统被锁定  在server上 mkdir会提示 Read-only file system!等提示 解决办法

查看下磁盘状态    

[xxx@xxx ~]#  fdisk -l 

Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00078f9c

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        5222    41940992   83  Linux

Disk /dev/vdb: 107.4 GB, 107374182400 bytes
255 heads, 56 sectors/track, 14685 cylinders
Units = cylinders of 14280 * 512 = 7311360 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf0ba90c3

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1       14685   104850872   83  Linux


查看文件系统类型

[xxx@xxx ~]# mount
/dev/vda1 on / type ext4 (rw,barrier=0)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

修复

重启系统后使用root进入单用户模式,运行

fsck.ext3 -y /dev/vda3

   注意  ext3的文件系统使用fsck.ext3修复 ext4文件系统使用fsck.etx4修复 修复过程有时候会比较长




3.最常见的情况的 也就是版本库没有写入权限  ll | grep xxx.git  检查下权限


[xxx@xxx xxx]# ll | grep xxx.git

drwxr-xr-x  7 git git 4096 11月  1 19:00 xxx.git

首先 目录用户及用户组为git  其次 755权限  如与上述不一样请运行

chown -R git.git xxx.git/
chmod -R 755 xxx.git/ 

如果帮到你  麻烦在下面留个言  如果我描写的情况跟你的有所不同 麻烦留言告知我一下 我会帮助你解决并完善本为以帮助更多人

 


 

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
你遇到的错误是因为 Git 在克隆仓库时无法创建文件名过长的文件,导致工作树检出失败。这是 Windows 系统的一个限制,因为 Windows 的 MAX_PATH 限制默认为 260 个字符。 --- ### ✅ 解决方案 #### 方法一:启用 Windows 的长路径支持(推荐) 从 Windows 10(版本 1607)开始,可以通过启用“长路径支持”来解决这个问题。 ##### 步骤如下: 1. **以管理员身份运行命令提示符(CMD)** 2. **执行以下命令启用长路径支持:** ```cmd reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f ``` 3. **重启计算机(可选,部分系统需要重启)** 4. **在 Git 中启用长路径支持:** ```bash git config --system core.longpaths true ``` > 注意:如果你没有管理员权限,可以使用 `--global` 代替 `--system`,但最好使用 `--system` 以确保所有用户生效。 --- #### 方法二:手动缩短文件路径(不推荐) 你可以尝试克隆到路径较短的目录,例如: ```bash git clone https://codehub-dg-g.huawei.com/x60102926/CP_WearableCloud_HealthDeveloperService_Operation_manger.git C:\git\repo ``` --- #### 方法三:使用 `git init` + `git remote` + `git checkout -f` 手动恢复 如果你已经克隆成功但 checkout 失败,可以这样做: ```bash # 初始化一个空仓库 git init # 添加远程地址 git remote add origin https://codehub-dg-g.huawei.com/x60102926/CP_WearableCloud_HealthDeveloperService_Operation_manger.git # 拉取数据 git fetch # 强制切换分支(忽略文件名过长的错误) git checkout -f master ``` --- ### ✅ 总结 最推荐的是 **方法一**:启用 Windows 的长路径支持并设置 Git 的 `core.longpaths` 配置项为 `true`。这样可以从根本上解决问题,适用于大多数项目。 ---
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值