如何获得干净的 git 存储库?这可能会丢失一些历史,但不是全部。此存储库可能已因并发修改和无效合并而损坏同步事物 https://syncthing.net/tool(机器中同步文件的工具)。
在每一个git commit
:
...
Could not read e7ac6796b130b61f0f382b0d31845239eeb61e6e
fatal: Failed to traverse parents of commit b5e5b4601495191a5700bcba4e2227515db77376
fatal: failed to run repack
...
On 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
On 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
git 版本 2.25.1
最好:
- 恢复较旧的
.stversions
通过“恢复版本”图形用户界面 https://github.com/syncthing/syncthing/pull/4602
- 验证此旧版本是否有效(git --no-optional-locks statu status https://git-scm.com/docs/git-status#_background_refresh,根据推荐马克·哈弗坎普 https://stackoverflow.com/users/619001/mark-haferkamp in 评论 https://stackoverflow.com/questions/60680946/how-to-clean-damaged-objects-in-git-repository/60681315?noredirect=1#comment110994738_60681315, and git fsck https://git-scm.com/docs/git-fsck)
- 尝试从当前损坏的存储库中重做文件,以恢复最新的源
- 添加、提交并推送这些更改。
话虽这么说,使用 git bundle 会更安全,因为我前面提到过 https://stackoverflow.com/a/9336980/6309.
The 阿尔乔姆 https://stackoverflow.com/users/511144/artyom更喜欢在评论中 https://stackoverflow.com/questions/60680946/how-to-clean-damaged-objects-in-git-repository/60681315?noredirect=1#comment107397532_60681315基于存档的选项:
tar --exclude-from=$backupexcludefile \
--xattrs --create --preserve-permissions --file - ~ | \
7za a -si -mx=3 $backupfile
这个想法保持不变:仅同步一个文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)