How to create a unique id of 40 characters in git? why is it unique?

I am trying to understand why the 40 character identifier used in git is unique and reliable.

Also what are the various inputs that are used to create a unique key.

+4
source share
1 answer

This is a SHA-1 hash of some header and commit information; see http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#object-details for hashing details and http://www.kernel.org/pub/software/scm /git/docs/user-manual.html#commit-object to hash a commit object. It is not guaranteed to be unique (since it is created using a multi-valued mapping), but the probability of a collision is so small as to be practically zero. You should consider identifiers as always unique.

+2
source

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


All Articles