3

What happens when GIT runs out of hash values for your Revisions?

Not that it would happen anytime soon, but theoretically it is possible.

gerrit
  • 24,025
  • 17
  • 97
  • 170
chrsi
  • 992
  • 9
  • 24
  • 3
    No, it's not possible *practically*, it's possible *theoriticaly*. – Agis Jan 14 '14 at 11:46
  • Git uses SHA-1, and I believe no actual collisions have been produced for that algorithm yet. Not to say that it won't - it will, by definition of being a fixed length digest. But it's all about probability of a collision. – Tim Jan 14 '14 at 11:49
  • Impossible even theoretically: these cryptographic hashes are *hashes,* -- that is digests calculated over the data, not GUIDs or some other *randomly* generated values. There is theoretical possibility for the so-called hash collisions but it has been chewed so many times on the Git mailing lists I advise you to do your own research and read them. – kostix Jan 14 '14 at 14:31

2 Answers2

4

According to the Git's Documentation

"If you do happen to commit an object that hashes to the same SHA-1 value as a previous object in your repository, Git will see the previous object already in your Git database and assume it was already written. If you try to check out that object again at some point, you’ll always get the data of the first object."

Kent Shikama
  • 3,910
  • 3
  • 22
  • 55
  • In addition to this. As git returns the same hash as a previous one then the repository of which it was made also was the same on a previous commit. This means no harm is none pointing to a previous commit. A hash is made over code and may never be the same to another hash over different code. If it does, you can stop using git. – Embed101 Jan 14 '14 at 11:58
  • 1
    @Embed101, that's not entirely true, hash collisions exist, it's the probability that matters and 10^-45 is fairly a safe bet. – gmaliar Jan 14 '14 at 14:16
2

I think this will help you understand better Probability of SHA1 collisions

I think you'd run out of space in the real world ;-)

Community
  • 1
  • 1
gmaliar
  • 5,294
  • 1
  • 28
  • 36