I’m trying to understand why the 40 character identifier used in git is unique and is it foolproof.
Also what are the various inputs that are used to generate the unique key.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is an SHA-1 hash of some header information and the commit; see http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#object-details for details of the hashing, and http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#commit-object for the commit object being hashed. It is not guaranteed to be unique (since it is created using a many-to-one mapping), but the probability of a collision are so small as to be practically zero. You should treat the IDs as always unique.