我正在尝试检查我的本地分支之一,名为 TEAM20-lab2-release。当我尝试这样做时,我收到一个不明确的引用名错误:
$ git branch TEAM20-lab2-release
warning: refname 'TEAM20-lab1-release' is ambiguous.
fatal: Ambiguous object name: 'TEAM20-lab1-release'.
这是我的分支列表:
$ git branch -a
TEAM20-lab1
* TEAM20-lab1-release
master
remotes/origin/HEAD -> origin/master
remotes/origin/master
最佳答案
这通常是因为您在另一个命名空间中使用了相同的名称(与您的分支相同):
- 类似于“remotes”命名空间:远程仓库的名称,如图 SO question 所示。 .
(因此 davitenio 在评论中要求git branch -a
) - 或“tags”命名空间:拥有以分支命名的标签也可以触发该消息(参见 blog post)
2016 年更新:Git 2.12(2017 年第一季度)在分支和标签共享相同名称时不会显示任何错误。
参见 commit b284495 (2016 年 10 月 31 日)Dennis Kaarsemaker (seveas
) .
参见 commit eef2bda (2016 年 10 月 28 日)Junio C Hamano (gitster
) .
(由 Junio C Hamano -- gitster
-- merge 于 commit 6c18dd4 ,2016 年 12 月 27 日)
push
: do not use potentially ambiguous default refspecWhen the user does the lazy "
git push
" with no parameters withpush.default
set to either "upstream
", "simple
" or "current
", we internally generated a refspec that has the current branch name on the source side and used it to push.However, the branch name (say "
test
") may be an ambiguous refname in the context of the source repository --- there may be a tag with the same name, for example.
This would trigger an unnecessary error without any fault on the end-user's side.Be explicit and give a full refname as the source side to avoid the ambiguity.
The destination side when pushing with the "current
" sent only the name of the branch and forcing the receiving end to guess, which is the same issue.
Be explicit there as well.
关于git - GIT 的名称不明确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5307956/