gpt4 book ai didi

git - 如何清理git存储库中损坏的对象?

转载 作者:行者123 更新时间:2023-12-04 10:24:33 29 4
gpt4 key购买 nike

如何获得一个干净的 git 存储库?这可能是因为失去了一些历史,但不是全部。此存储库可能已被 SyncThing 的并发修改和无效 merge 损坏。工具(在机器中同步文件的工具)。

git commit :

...
Could not read e7ac6796b130b61f0f382b0d31845239eeb61e6e
fatal: Failed to traverse parents of commit b5e5b4601495191a5700bcba4e2227515db77376
fatal: failed to run repack
...

git fsck --full
Checking object directories: 100% (256/256), done.
Checking objects: 100% (26828/26828), done.
broken link from commit b5e5b4601495191a5700bcba4e2227515db77376
to commit e7ac6796b130b61f0f382b0d31845239eeb61e6e
broken link from tree f2678f1595a2eebd798afb9496614a09eb75d1b6
to tree ecd48fc55a31781d2b4cbad0629c10590de0b1a5
broken link from tree 1259b1ca62274228c9c42aaf4a9a2276a5b60a32
to blob 00162d2c6425ae3166187089ff2724cb2bce23db
dangling commit f5079404103ce1343d46884219cbea7d73d0e849
dangling blob b03a78f393908690b5a395b2842c2d99b1d185e7
dangling blob 134bba35a1bda0ed2c4e57640738d8d0e999e483
dangling blob 1180e69eaaa1915c12a4c1d77b20bbc08ad60633
dangling commit f39624880f4f97131d1d56deb7a3ba5289186015
dangling commit 27d46e5a9fc0d28eb7b5229cb9ca06cbf1d6d065
missing blob 00162d2c6425ae3166187089ff2724cb2bce23db
dangling commit 5e2a2d64abce8e24e83f1d5c59f096b6c7180959
dangling commit 273b659b039d66014957dbe1fa3eb975e80b9d03
dangling commit 084d6f70f7b72e1ee4bfd181ec00f8840b9abe7a
dangling commit 5657bf6382d23a2c216af7364612ef73931ad88a
dangling blob cb6bd151bdfe88348d248437b8ddb77eb4669cab
dangling blob aa7ea55c9a797f1ccb1285c1a2fdf81c7fbcacf5
missing commit e7ac6796b130b61f0f382b0d31845239eeb61e6e
missing tree ecd48fc55a31781d2b4cbad0629c10590de0b1a5
dangling commit f1f62b99255d06356be53666bfac72a67b93f264

git gc :
error: Could not read e7ac6796b130b61f0f382b0d31845239eeb61e6e
fatal: Failed to traverse parents of commit b5e5b4601495191a5700bcba4e2227515db77376
fatal: failed to run repack

尝试克隆此存储库:
> git init 
> git remote add parent <mypath to the broken repo>
...
> git pull parent master
remote: error: Could not read e7ac6796b130b61f0f382b0d31845239eeb61e6e
remote: fatal: Failed to traverse parents of commit b5e5b4601495191a5700bcba4e2227515db77376
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: protocol error: bad pack header

版本 2.25.1

最佳答案

最好是:

  • 恢复较旧的 .stversions通过 "Restore Version" gui
  • 验证此旧版本是否有效( git --no-optional-locks statu status ,正如 Mark Haferkamp 中的 the comments git fsck 所推荐的)
  • 尝试从当前损坏的 repo 中重做文件,以获取最新的源
  • 添加、提交和推送这些更改。

  • 话虽如此,使用 git bundle 会更安全,因为我 mentioned before .
    OP Artyom更喜欢 in the comments基于存档的选项:
    tar --exclude-from=$backupexcludefile \
          --xattrs --create --preserve-permissions --file - ~ | \
    7za a -si -mx=3 $backupfile
    想法保持不变:只同步一个文件。

    关于git - 如何清理git存储库中损坏的对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60680946/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com