What does a git SHA depend on?

前端 未结 2 1209
我寻月下人不归
我寻月下人不归 2021-01-12 05:30

I was wondering what are all the parameters a git SHA depends on ? I am guessing there would be some other parameters like timestamp etc., besides content of the commit, on

2条回答
  •  一生所求
    2021-01-12 06:21

    There are several different types of objects stored in the Git repository. A blob object stores the raw data of a file and the tree object stores the file mode (e.g. whether it is read-only), object type and name.

    You can find more details in the Git Community Book.

    There are so many hash values that the chances of accidental collision are vanishingly small.

    However, truly identical content will have an identical hash: so if two people independently make identical changes to a file then the two (identical) blob objects will have the same hash; the commit objects will be different and will have different hashes, but both commits will refer to the same blob hash. If those two commits are later merged, only one copy of the blob will remain (which is fine because the content is identical).

提交回复
热议问题