2

Any idea why git hash-object has different outcome from shasum and openssl commands ?

➜ printf test | shasum
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3  -

➜  printf test | git hash-object --stdin
30d74d258442c7c65512eafab474568dd706c430

➜  echo -n "test" | shasum
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3  -
odedpr
  • 147
  • 1
  • 9
  • 1
    http://stackoverflow.com/questions/552659/how-to-assign-a-git-sha1s-to-a-file-without-git/552725#552725 – Vili Nov 14 '16 at 07:20

1 Answers1

3

Git adds a header which contains the type and length of the content and after that it generates the hash. That's why you are getting it different.

Here is a more detailed description.

mallaudin
  • 4,744
  • 3
  • 36
  • 68