0

As you know we can use short hash as commit id. But I wonder why there is a long hash?

Thanks.

Matt
  • 12,848
  • 2
  • 31
  • 53

1 Answers1

2

Hash is that long to reduce risk of collision

https://en.m.wikipedia.org/wiki/Hash_collision

Pierwiastek
  • 134
  • 9
  • If there is a risk of collision why we are using short hash? – Altay Turan Nov 12 '22 at 08:22
  • 1
    @AltayTuran Just for convenience. If there are two objects in the repository that are identical in the abbreviated form, then you must use a longer abbreviation. – j6t Nov 12 '22 at 08:31
  • 1
    When Git prints abbreviated hashes, it ensures that they are unique *at the time they are printed*; they could become ambiguous later as the repository grows. – j6t Nov 12 '22 at 08:32