Why does Git use SHA-1 (or SHA-256) hashes for commits instead of simple incrementing version numbers?

Last updated 6 July 2026

  • Git is distributed, so incrementing numbers would collide without a central coordinator. Content hashes are globally unique with no coordination.

  • Hashes cover the tree and parents, so changing any historical byte changes every downstream ID, making tampering detectable.

  • SHA-1 has known collision attacks, so Git added SHA-256 support.

  • https://lwn.net/Articles/715716/
  • https://git-scm.com/docs/hash-function-transition
  • https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F
  • https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
  • https://github.blog/open-source/git/highlights-from-git-2-52/
  • https://lwn.net/Articles/898522/
  • https://github.blog/news-insights/git-2-6-including-flexible-fsck-and-improved-status/
All Git interview questions