Both Git and GitHub display short versions of SHAs -- just the first 7 characters instead of all 40 -- and both Git and GitHub support taking these short SHAs as arguments.
E.g. git show 962a9e8
E.g. https://github.com/joyent/node/commit/962a9e8
Given that the possibility space is now orders of magnitude lower, "just" 268 million, how do Git and GitHub protect against collisions here? And how do they handle them?
These short forms are just to simplify visual recognition and to make your life easier. Git doesn't really truncate anything, internally everything will be handled with the complete value. You can use a partial SHA-1 at your convenience, though:
Two notes here:
If you type y anywhere on the GitHub page displaying a commit, you will see the full 40 bytes of said commit.
That illustrates emboss's point: GitHub doesn't truncate anything.
And 7 hex digits (28 bits) isn't enough since 2010 anyway.
See commit dce9648 by Linus Torwalds himself (Oct 2010, git 1.7.4.4):
(BK = BitKeeper)
I have a repository that has a commit with an id of
000182eacf99cde27d5916aa415921924b82972c
.shows the revision, but
prints
(If you're curious, it's a clone of the git repository for git itself; that commit is one that Linus Torvalds made in 2005.)