git SHA1 0000000000000000000000000000000000000000(全为零),这正常吗?

标签 git sha

我在 git 中有一个尚未提交的分支,SHA1 0000000000000000000000000000000000000000(全为零),这是正常的还是我损坏了 git 存储库?

请不要回答"is",即 2^160 中有一个,或 0.00000000000000000000000000000000000000000000006842277657836021% 的概率具有该 SHA1。

我相当安全,我不是那个在他的 git 存储库中获得 000000000000000000000000000000000000000 的 SHA1 的幸运儿。

最佳答案

请注意,您可以一直找到“全零 SHA1”到 commit f65fdf (2005 年 6 月 30 日,git v0.99)

Linus Torvalds:

A "old ref" of all zeroes is considered a "don't care" ref, and allows us to say "write the new ref regardless of what the old ref contained (or even if it existed at all)".

This allows (if git-send-pack were to do it) creating new refs, and fixing up old ones.


作为SzG提到in the comments ,这是您在 Git receive/update hooks and new branches 中找到的 SHA1 类型,代表不存在对象的“旧引用”(而“新引用”将创建所述对象,如分支)。

关于git SHA1 0000000000000000000000000000000000000000(全为零),这正常吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18977462/

相关文章:

git - 管理来自同一系统和不同用户名的多个 github 存储库

windows - 推送到 Azure DevOps git 存储库 : GCM: NullReferenceException

c# - C# 中未指定类型的变量?

c++ - SHA1+RSA - 帮助在 C++ 中使用 Botan

java - android中sha256哈希计算错误

c# - 为什么 SHA1.ComputeHash 在多线程的高负载下会失败?

javascript - 在两个 NodeJS 微服务之间共享自定义代码

git - 使用 libgit2sharp 检查远程分支

git - 为什么 git merge 有时会删除不应该更改的更改?

python - SHA1验证功能