How does Git(Hub) handle possible collisions from short SHAs?

前端 未结 3 1897
轮回少年
轮回少年 2020-12-24 02:10

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.<

3条回答
  •  悲哀的现实
    2020-12-24 02:32

    I have a repository that has a commit with an id of 000182eacf99cde27d5916aa415921924b82972c.

    git show 00018
    

    shows the revision, but

    git show 0001
    

    prints

    error: short SHA1 0001 is ambiguous.
    error: short SHA1 0001 is ambiguous.
    fatal: ambiguous argument '0001': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions
    

    (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.)

提交回复
热议问题