GIT Packfile 声称有更多对象,无法访问

标签 git object git-pull

我遇到了很多关于我的包文件的错误,这些错误看起来很隐蔽, 这是一个非常可怕的交易,因为这是一个实时网站,我不确定如何处理它, 也许有人可以告诉我,这是怎么回事。

似乎我缺少了一个对象,而且我的 packfile 的计数也有问题?

remote: Counting objects: 25733, done.
remote: Compressing objects: 100% (12458/12458), done.
remote: Total 19185 (delta 6914), reused 17995 (delta 6535)

Receiving objects: 100% (19185/19185), 1.69 GiB | 465 KiB/s, done.
Resolving deltas: 100% (6914/6914), completed with 1058 local objects.

error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed

error: unable to find e17196d88ae91dea07b4d61716b91dac581fb131

error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed

fatal: object e17196d88ae91dea07b4d61716b91dac581fb131 not found

编辑 另一个似乎已经发芽了,所以现在我有....

.git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack 
.git/objects/pack/pack-931e28ca404e28040a10085dd1534ef12cf18c6d.pack

我已经尝试将它们复制到 www-root 之后,然后删除它们,现在正在运行 git-gc我将尝试使用 git fetch origin 重新获取来源

git-gc现在返回

bad sha1 file: .git/objects/05/.a2e1939ce5a53d5ec7c3cacc4df97acd09c6af.hdgIVe
bad sha1 file: .git/objects/80/.1a75684e9d869e9ed7c1ded674c55caa17c524.YUr1Yu
bad sha1 file: .git/objects/8c/.7e8381b3e0d0a1f1d4fa328f0dda0a1dbd814a.L0255H
bad sha1 file: .git/objects/c5/.32926ac2d67785cb8580b885ac3d3fd7075f57.rDsW4H
Removing stale temporary file .git/objects/pack/tmp_pack_jnP5qn

最佳答案

如“Problems with corrupt git repo ”及其 associated discussion 中所述:

Many of these objects are then packed together into a packfile to save space. You corrupted these packfiles by changing their content – even worse: changing the length of their content.
git fsck does not actually fix anything about a git repository, it just checks for errors and reports them.
git unpack-objects on the other hand is able to unpack as much as possible from a corrupted packfile, but you will still have errors in your repo, as git fsck --full will report.
See "How to fix a broken repository?" or "How to remove all broken refs from a repository?".


请注意,对于 Git 2.4.3(2015 年 6 月),不再有警告 packfile .git/objects/pack/pack-xxx.pack cannot be accessed
这允许只关注实际错误。

请参阅 commit 319b678 [2015 年 3 月 31 日]。
(由 Jeff King (peff) merge 到 Junio C Hamano -- gitster -- ,2015 年 6 月 5 日)

与往常一样,Peff 的解释很有启发性:

sha1_file: squelch "packfile cannot be accessed" warnings

When we find an object in a packfile index, we make sure we can still open the packfile itself (or that it is already open), as it might have been deleted by a simultaneous repack.
If we can't access the packfile, we print a warning for the user and tell the caller that we don't have the object (we can then look in other packfiles, or find a loose version, before giving up).

The warning we print to the user isn't really accomplishing anything, and it is potentially confusing to users.

In the normal case, it is complete noise; we find the object elsewhere, and the user does not have to care that we racily saw a packfile index that became stale. It didn't affect the operation at all.

A possibly more interesting case is when we later can't find the object, and report failure to the user. In this case the warning could be considered a clue toward that ultimate failure. But it's not really a useful clue in practice. We wouldn't even print it consistently (since we are racing with another process, we might not even see the .idx file, or we might win the race and open the packfile, completing the operation).

This patch drops the warning entirely (not only from the fill_pack_entry site, but also from an identical use in pack-objects).
If we did find the warning interesting in the error case, we could stuff it away and reveal it to the user when we later die() due to the broken object. But that complexity just isn't worth it.


在 Git 2.22.1(2019 年第 3 季度)中,“git update-server-info”曾经在其输出中留下过时的包文件,这一问题已得到纠正。

参见 commit 3c91e99commit e941c48(2019 年 5 月 23 日)。
帮助:Eric Wong (ele828) .
(由 Jeff King (peff)Junio C Hamano -- gitster -- merge ,2019 年 7 月 25 日)

server-info: do not list unlinked packs

Having non-existent packs in objects/info/packs causes dumb HTTP clients to abort.

v2: use single loop with ALLOC_GROW as suggested by Jeff King


在 Git 2.35(2022 年第 1 季度)中,tmp-objdir API 中有一个新接口(interface),以帮助在内核中使用隔离功能。

参见 commit 776d668commit ecd81df(2021 年 12 月 6 日)。
(由 commit b3cecf4 merge 到 Neeraj Singh (neerajsi-msft) ,2022 年 1 月 3 日)

tmp-objdir: new API for creating temporary writable databases

Based-on-patch-by: Elijah Newren
Signed-off-by: Neeraj Singh
Reviewed-by: Elijah Newren

The tmp_objdir API provides the ability to create temporary object directories, but was designed with the goal of having subprocesses access these object stores, followed by the main process migrating objects from it to the main object store or just deleting it.
The subprocesses would view it as their primary datastore and write to it.

Here we add the tmp_objdir_replace_primary_odb function that replaces the current process's writable "main" object directory with the specified one.
The previous main object directory is restored in either tmp_objdir_migrate or tmp_objdir_destroy.

For the --remerge-diff usecase, add a new will_destroy flag in struct object_database`` to mark ephemeral object databases that do not require fsync durability.

Add 'git prune'(man) support for removing temporary object databases, and make sure that they have a name starting with tmp_ and containing an operation-specific name.

修剪消息来自:

Removing stale temporary file ...

收件人:

Removing stale temporary directory ...

关于GIT Packfile 声称有更多对象,无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11401434/

相关文章:

git - 为什么 git log 在 git fetch 之后没有显示任何新内容?

git - 如何解决 Git "CONFLICT (modify/delete)"?

git - Jira如何链接到git?

java - 从一个类中构造的对象在另一个类中创建数组列表

java - 在集合数据结构中按类类型或类名称对对象进行排序

java - 安卓 : Serializing an array of Objects

git - 如何获取/pull 与通配符字符串匹配的多个分支?

git - 如何使用 pull 更新本地存储库

git - 在 git 中用孤立分支覆盖主分支

git - 您的配置指定与远程的 <branch name> merge ,但未获取此类引用。?