Get the latest tech news

How short can Git abbreviate? (2013)


How short can a Git hash be abbreviated?  A full SHA-1 hash is 160 bits, 40 hex characters, which is a bit long to talk about and retype when you’re not just copy-pasting.  Therefore most peo…

However, since hash functions like SHA-1 have approximately random distribution, you easily can and will run into the birthday problem at this level. As Linus noted in that second link, Git will now make sure that the abbreviated hashes it prints are currently long enough to be unique, but that’s no guarantee against future collisions. Finally, when you reference a Git hash for posterity, e.g. in another commit message, I’d recommend always using the full value.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Git

Git

Photo of Git abbreviate

Git abbreviate

Related news:

News photo

Ask questions about Git repositories from a web UI

News photo

Git 2.45 Begins Landing Code For SHA1 & SHA256 Interoperability For Repositories

News photo

Notes on Git's Error Messages