如何修复Git零填充文件模式警告 [英] How to fix Git zero-padded file modes warning

查看:165
本文介绍了如何修复Git零填充文件模式警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信,我的 Git 存储库状态不佳,其中我做

I believe, my Git repository is not in good shape, wherein when I do a

git fsck

我在顶部得到以下警告.

I get the following warnings at the top.

103b5dd53f7a96f8e3a02aea0d3d4d9bb19644ed: contains zero-padded file modes
bb4729593e76f66b46292ad6ae61bfe909558337: contains zero-padded file modes
4709aa73691ce7da36dd22ccfd157c4514395330: contains zero-padded file modes

我尝试了以下步骤(由同事建议)来查找有问题的提交,以便我可以纠正它们.我尝试了以下方法.

I tried the following (suggested by a colleague) to find the offending commits, so that I could correct them. I tried the following methods.

  1. 遍历git rev-list HEAD中的所有提交.
  2. 对于每个提交,执行git ls-tree -rd来查找所有相关对象 SHAs .
  3. 查看其中是否与git fsck中的上述内容匹配.
  1. Go through all the commits from git rev-list HEAD.
  2. For each of those commits, do a git ls-tree -rd to find all the relevant object SHAs.
  3. See if any of those, matches with the above in the git fsck.

上面的逻辑对我来说似乎是正确的,但它无法找到有问题的提交.

The logic of the above seemed right to me, but it was not able to find the offending commit.

git rev-list --all --remotes | while read commit; do git ls-tree -rd $commit | grep -E "103b5dd53f7a96f8e3a02aea0d3d4d9bb19644ed|bb4729593e76f66b46292ad6ae61bfe909558337|4709aa73691ce7da36dd22ccfd157c4514395330" && echo -e "HIT @ $commit\n\n"; done

我们在这里想念什么?我们如何找到有问题的提交或文件有问题?最后,我要修复存储库.

What are we missing here? How can we find either the offending commit or file is having the problem? At the end, I want to fix the repository.

推荐答案

从注释中添加解决方法作为答案:

Adding workaround from comments as answer:

使用 git fast-export ,然后 git fast-import 解决了该问题,但SHA值将发生变化,并且不会引用树引用.

Rebuilding the repo using git fast-export and then git fast-import resolves the problem but SHA values will change and tree references are not brought over.

创建一个新的空存储库:

Create a new empty repository:

mkdir /newrepo
cd /newrepo
git init

使用fsck警告回到旧版本:

Go back to the old one with the fsck warnings:

cd /oldrepo

使用从旧数据快速导出到新存储库中的快速导入的方式来放置数据

Pipe the data over using fast-export from old data to fast-import in the new repo

git fast-export --all | (cd /newrepo && git fast-import)

这篇关于如何修复Git零填充文件模式警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆