如何解决 git 中分支名称和提交哈希之间的歧义?

How to resolve ambiguity between branch name and commit hash in git?

我有一个名为 0726b 的分支,我想将我当前的工作副本与该分支进行比较。 显然还有一个提交的哈希值以该序列开头,因为我得到

$ git diff 0726b
warning: refname '0726b' is ambiguous.

如何告诉 git 它应该将参数作为分支名称?

试试这个:

git diff refs/heads/0726b

refs/heads/0726b 指定一个名为 0726b 的分支。 文件 ./git/refs/heads/0726b 包含此分支指向的提交哈希。