检查git回购的完整性 [英] checking integrity of a git repo

查看:124
本文介绍了检查git回购的完整性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有一张磁盘在访问git repo时报告了一长串不可恢复的读取错误时,我担心我会推动其他回购,这可能会将错误的内容转发给他们。顺便说一句,在使用commit / push / pull访问repo时,git命令没有报告任何错误。但是在访问repo后,我总是在磁盘上的 dmesg 中带有不可恢复的读取错误。所以必须有一些文件生效,但也许内容是多余的。



我知道:

  git fsck --full 

会检查回购,但我想要要问:

没有报告任何错误(也许一些悬而未决的提交/斑点并不重要,因为我读)意味着完整的回购处于有效状态?尤其是,不仅参考文件和文件已存在,而且所有文件的内容都是有效的?我找不到的是,有一种类似校验和的方式可以验证存储在git数据库中的所有对象的全部内容。

解决方案


没有报告任何错误(也许一些悬而未决的提交/ blob并不重要,因为我读)意味着完整的repo处于有效状态?


是的。 git fsck --full (和 - 完整是默认值)会检查所有对象及其连接。 p>


尤其是那些引用和文件不仅存在,而且
也是所有文件的内容都是有效的?我找不到的是
有一些校验和,可以验证存储在git数据库中的所有对象的
全部内容。


Git拥有正确的校验和。



Git中的所有东西都是一个对象。每个对象都有一个ID。这些ID是内容和连接的校验和。如果内容或连接发生变化,则ID不再有效。



例如,提交ID基本上是一个校验和...




  • 所有文件的内容和权限(git称之为blob)在提交点(它们有自己的ID)。

  • 提交的字段,如作者,日期,日志消息等...

  • 父提交的提交ID。



如果其中任何更改,则ID /校验和不再有效。这是一个令人难以置信的优雅系统。



如果该磁盘仍然给你错误,你应该更换该磁盘。


After I had a disk which reported a long list of "unrecoverable read errors" while accessing a git repo, I fear that i did some pushes to other repos which maybe forward wrong content to them. BTW non of the git commands did report any error while accessing the repo with commit/push/pull. But after accessing the repo I get always new entrys in dmesg with unrecoverable read errors on the disk. So there must be some files effected, but maybe the content is redundant.

I know that:

git fsck --full 

will check the repo, but I want to ask:

Did not reporting any errors ( maybe some dangling commits/blobs are not critical as I read ) mean that the complete repo is in valid state? Especially that not only that references and files are existing, but also the content of all files are valid? What I can't find is that there is something like a checksum to make it possible to verify the full content of all the objects stored in the git database.

解决方案

Did not reporting any errors ( maybe some dangling commits/blobs are not critical as I read ) mean that the complete repo is in valid state?

Yes. git fsck --full (and --full is the default) checks all the objects and their connections.

Especially that not only that references and files are existing, but also the content of all files are valid? What I can't find is that there is something like a checksum to make it possible to verify the full content of all the objects stored in the git database.

Git has checksums baked right in.

Everything in Git is an object. Every object has an ID. The IDs are a checksum of the content and connections. If the content or connections change, the ID is no longer valid.

For example, a commit ID is basically a checksum of...

  • The contents and permissions of all files (git calls them "blobs") at the point of that commit (which have their own IDs).
  • The fields of the commit like author, date, log message, etc...
  • The commit IDs of the parent commits.

If any of those change, the ID/checksum is no longer valid. It's an incredibly elegant system.

And if that disk is still giving you errors, you really should replace that disk.

这篇关于检查git回购的完整性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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