Git SHA1 00000000000000000000000000000000000000000000 (all zeros), is this normal?

I still have some branch in git with SHA1 00000000000000000000000000000000000000000000 (all zeros), is this normal or did I damage the git repository?

Please do not answer yes, one of 2 ^ 160, or 0.000000000000000000000000000000000000000000000000006842277657836021% chance of having this SHA1.

I am safe enough. I am not a happy guy who got SHA1 from 0000000000000000000000000000000000000000 in his git repository.

+6
source share
2 answers

A commit includes, among other metadata, a commit date. Thus, the commit hash cannot be displayed until the commit has been created. What you see is not a SHA commit, it is just the default value used in the user interface.

+8
source

Please note: you can find "all-zeros SHA1" on the way back to commit f65fdf (June 30, 2005, v0. 99 from git)

Linus Torvalds:

The "old ref" of all zeros is considered to "not care" ref and allows us to say "write a new reference no matter what the old ref contains (or even if it existed at all)."

This allows (if git-send-pack should have done this) by creating new links and fixing old ones.


As SzG is mentioned in the comments , this is the kind of SHA1 that you will find in Git receive / update hooks and new branches representing the “old-ref” for the nonexistent object (while the “new-ref” would create the mentioned object as a branch )

+7
source

Source: https://habr.com/ru/post/954485/


All Articles