git - GIT 的名称不明确?

标签 git branch

我正在尝试检查我的本地分支之一,名为 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 refspec

When the user does the lazy "git push" with no parameters with push.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/

相关文章:

带通配符的 Git blame

git - 本地 Git 存储库中的 Zeppelin Notebook 存储

version-control - 引用 Mercurial 中的当前书签

git - 从 master 分支中删除单个 merge 分支

linux - Etckeeper + git 和远程服务器

java - mvn命令错误

git - 如何使用 Git 管理 Kiln 的分支?

version-control - 分支模式/策略

git - 如何确定 Git 分支的创建时间?

git - IntelliJ git merge 工具