

git上传对象文件错误解决方案 - huxiaofeng
source link: https://www.cnblogs.com/huxiaofeng1029/p/17436594.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

git上传对象文件错误解决方案
时隔一个星期, 当我再次完成开发之后, 准备将代码上传, 却出现了一个上传代码的错误, 记录一下错误和解决方案

解决方案:
- 运行
git fsck --full
(base) ifeng@ubuntu:~/Desktop/luffycity$ git fsck --full
error: 对象文件 .git/objects/c9/e590416bbe286dc32a17ddf14670ebb52e4520 为空
error: 对象文件 .git/objects/c9/e590416bbe286dc32a17ddf14670ebb52e4520 为空
fatal: 松散对象 c9e590416bbe286dc32a17ddf14670ebb52e4520(保存在 .git/objects/c9/e590416bbe286dc32a17ddf14670ebb52e4520)已损坏
- 在.git目录下find . -type f -empty -delete -print 会删除全部空文件
(base) ifeng@ubuntu:~/Desktop/luffycity$ cd .git
(base) ifeng@ubuntu:~/Desktop/luffycity/.git$ find . -type f -empty -delete -print
./FETCH_HEAD
./objects/cd/cd1a2512ad47d7e2290b02a2a77ea79277e7c9
./objects/c9/e590416bbe286dc32a17ddf14670ebb52e4520
./objects/6a/871d8bf9b841b8febcc3a4c7c6c17ac9557a79
./objects/82/01d128f3356e1cbe2c2413ff422c53974b80db
./objects/2c/cdc2e45330ea23f1fb2f1cf133c7e9dc54680b
./objects/2c/65cffca3b6403b675f19701f41e64f3166401f
./objects/71/420f984a2d039563d7b80cb295f37e55b45ad3
- 再次运行
git fsck --full
, 还是有错,head指向元素不存在,是之前一个空文件,我们已经删了
(base) ifeng@ubuntu:~/Desktop/luffycity/.git$ git fsck --full
正在检查对象目录: 100% (256/256), 完成.
error: refs/heads/feature/user:无效的 sha1 指针 c9e590416bbe286dc32a17ddf14670ebb52e4520
error: refs/remotes/origin/feature/user:无效的 sha1 指针 c9e590416bbe286dc32a17ddf14670ebb52e4520
error: HEAD:无效的 sha1 指针 c9e590416bbe286dc32a17ddf14670ebb52e4520
error: 71420f984a2d039563d7b80cb295f37e55b45ad3:cache-tree 中无效的 sha1 指针
悬空 blob 38fae659ca427cf6d82705f281bd6549bb3bef41
悬空 tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
悬空 blob a517beeb35b0c70cd4b361ec6e085e58ef47c225
- 手动获取最后两条reflog, 运行
tail -n 2 .git/logs/refs/heads/feature/user
, 后面的部分就是上面信息的路径
(base) ifeng@ubuntu:~/Desktop/luffycity$ tail -n 2 .git/logs/refs/heads/feature/user
03f77f97f3f2f687186f74b7ceaee4e9c6103dde 377adde104760d582bf76985a95f5c2262491b1c ifeng <[email protected]> 1684228848 +0800 commit: feature: 注册功能实现流程-客户端请求发送短信并实现短信倒计时冷却提示!
- head当前是指向最新的那一条记录, 所以我们看一下parent commit即倒数第二次提交
git show 377adde104760d582bf76985a95f5c2262491b1c
(base) ifeng@ubuntu:~/Desktop/luffycity$ git show 377adde104760d582bf76985a95f5c2262491b1c
可以看到内容是正常的
-
那么我们就重新设置head, 使其指向倒数第二条
git update-ref HEAD 377adde104760d582bf76985a95f5c2262491b1c
-
最后我们git push的时候发现还是有错
(base) ifeng@ubuntu:~/Desktop/luffycity$ git push origin feature/user
error: refs/remotes/origin/feature/user 没有指向一个有效的对象!
error: refs/remotes/origin/feature/user 没有指向一个有效的对象!
To gitee.com:i__feng/luffycity.git
! [rejected] feature/user -> feature/user (fetch first)
error: 无法推送一些引用到 '[email protected]:i__feng/luffycity.git'
提示:更新被拒绝,因为远程仓库包含您本地尚不存在的提交。这通常是因为另外
提示:一个仓库已向该引用进行了推送。再次推送前,您可能需要先整合远程变更
提示:(如 'git pull ...')。
提示:详见 'git push --help' 中的 'Note about fast-forwards' 小节。
根据错误提示执行git pull origin feature/user
我们从远程仓库自动合并feature/user
(base) ifeng@ubuntu:~/Desktop/luffycity$ git pull origin feature/user
来自 gitee.com:i__feng/luffycity
* branch feature/user -> FETCH_HEAD
自动合并 luffycityapi/luffycityapi/apps/users/serializers.py
Merge made by the 'recursive' strategy.
- 最后再去提交重新提交我们的代码就完成了
(base) ifeng@ubuntu:~/Desktop/luffycity$ git push origin feature/user
枚举对象中: 28, 完成.
对象计数中: 100% (27/27), 完成.
使用 4 个线程进行压缩
压缩对象中: 100% (13/13), 完成.
写入对象中: 100% (14/14), 2.16 KiB | 736.00 KiB/s, 完成.
总共 14 (差异 6),复用 0 (差异 0)
remote: Powered by GITEE.COM [GNK-6.4]
To gitee.com:i__feng/luffycity.git
c9e5904..ff1c1a9 feature/user -> feature/user
Recommend
-
2
文件上传时报413错误 作者: wencst 分类: Uncategorized,程序...
-
5
V2EX › git 求助使用 git lfs 上传大文件到 github 失败 ecoo · 5 小时 59 分钟前 · 327 次点击
-
4
-
10
组合搜索组件 1. 先展示一下使用效果: ...
-
5
DRF中版本控制的五种情况(源码分析) 在restful规范中要去,后端的API中需要体现版本。 drf框架中支持5种版本的设置。 1. URL的GET参数传递(*) 示例: user/?v...
-
3
DRF认证组件(源码分析) 1. 数据库建立用户表 在drf中也给我们提供了 认证组件 ,帮助我们快速实现认证相关的功能,例如: # models.py from django.db import models class Us...
-
9
Django的Message组件(源码分析) # MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage' # MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage' MESSAGE_STOR...
-
5
项目部署上线 想要将django项目部署在服务器上,本质上需要三大部分...
-
5
Supervisor启动并管理Celery相关进程 关于celery在运行过程中, 默认情况下是无法在关机以后自动重启的。所以我们一般开发中会使用supervisor进程监控来对celery程序进行运行监控!当celery没有启动的情况下,supe...
-
6
前端处理 “大” 一直是一个痛点和难点,比如大文件、大数据量。虽然
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK