在执行git pull
后遇到类似错误时,Stackoverflow上有很多关于如何修复存储库的帖子:
错误:对象文件.git / objects / 48 / 088f00d90b0d27de65336bb9ed9a75b0cfed33为空 致命:松散的物体48088f00d90b0d27de65336bb9ed9a75b0cfed33(存储在.git / objects / 48 / 088f00d90b0d27de65336bb9ed9a75b0cfed33中)已损坏
我很想知道的是:什么是导致此错误的事情的例子?
有些问题报告了系统重启或电池在git pull中间死机等问题。导致这个问题的这种中断是有道理的。
然后还有其他问题报告问题一再发生,例如在this post中,没有明确指示原因。
答案 0 :(得分:1)
使用Git客户端执行对Git存储库的更改时,不应发生这些错误。从文档中,请参阅Object Storage以了解Git如何存储其对象:
腐败的松散物体是指其状态偏离此设计的任何物体(另请参阅What are the “loose objects” that the Git GUI refers to?)。
除了系统重启或电池耗尽外,还有其他原因包括
如果你有点好奇,试试这个人为的例子:
$ git init bad-apple
Initialized empty Git repository in /tmp/bad-apple/.git/
$ cd bad-apple
$ touch README; git add .; git commit -m "Add a transitional fossil"
[master (root-commit) ca3ea96] Add a transitional fossil
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README
# Get the commit object id
$ git rev-parse HEAD
ca3ea9630c0f01afc286589c4072db9c43262d63
# Git tries to help you not shoot yourself in the foot
$ chmod +w .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63
# Empty out the commit object file and you broke it
$ truncate .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63 --size 0
error: object file .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63 is empty
error: object file .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63 is empty
fatal: loose object ca3ea9630c0f01afc286589c4072db9c43262d63 (stored in .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63) is corrupt