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

前端 未结 3 1899
轮回少年
轮回少年 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条回答
  •  猫巷女王i
    2020-12-24 02:22

    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:

    Git is smart enough to figure out what commit you meant to type if you provide the first few characters, as long as your partial SHA-1 is at least four characters long and unambiguous — that is, only one object in the current repository begins with that partial SHA-1.

提交回复
热议问题