You changed the type of the object you wrote the hash with.
From git hash-object
-t <type>
Specify the type (default: "blob").
You went from the default blob to commit.
And the object actually written start with the object type, which is part of what the sha1 has to compute.
See:
- "Why does git hash-object return a different hash than openssl sha1?"
- "Assigning Git SHA1's without Git"
Git calculates the SHA1 for a file (or, in Git terms, a "blob"):
sha1("blob " + filesize + "\0" + data)
That changes the content of what is taken into account by the sha1.
With -t commit
, you modify that prefix (it is no longer 'blob
'), and since the content is different, the sha1 is also different.
You can do a:
python -c "import zlib,sys;print repr(zlib.decompress(sys.stdin.read()))" < .git/objects/02/b365d4af3ef6f74b0b1f18c41507c82b3ee571:
The first word will be the type of the content
For further reference check How Git Works