我对Josh Stone's analysis of sha1 abbreviation collisions很感兴趣。
假设有人写下了一个缩写的提交id,8b82547e33
,当时它是明确的。但从那时起,已经创建了具有相同前缀的其他对象,所以现在git会告诉您(出于某种原因,有两次):
$ git show 8b82547e33
error: short SHA1 8b82547e33 is ambiguous.
error: short SHA1 8b82547e33 is ambiguous.
fatal: ambiguous argument '8b82547e33': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
现在,作为一个人类,如果git只给我显示模糊的对象,我可能会说出我指的是哪个对象。我怎样才能实现下面这样的结果呢?
$ git objects-starting-with 8b82547e33
8b82547e33e: commit: l2tp: Restore socket refcount when sendmsg succeeds
8b82547e338: tree [2 files, 26 subtrees]
(注意:以上示例使用的是相对较新的http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git克隆。)
发布于 2014-12-12 01:31:54
您可以使用git rev-parse
,假设您至少有一个完整散列的4位前缀。
git rev-parse --disambiguate=8b82547e33
https://stackoverflow.com/questions/27428441
复制相似问题