Ambiguous Names with GIT?

后端 未结 3 739
灰色年华
灰色年华 2021-01-03 00:08

I\'m trying to check out one of my local branches, named TEAM20-lab2-release. When I try to do this, I get an ambiguous refname error:

$ git branch TEAM20-l         


        
3条回答
  •  粉色の甜心
    2021-01-03 01:03

    It usually is because you have the same name (than your branch) used in another namespace:

    • like the "remotes" namespace: the name of a remote repo as illustrated by this SO question.
      (Hence davitenio's request for git branch -a in the comments)
    • or the "tags" namespace": having a tag named after a branch can also trigger that message (see this blog post)

    Update 2016: Git 2.12 (Q1 2017) won't show any error if a branch and a tag are sharing the same name.

    See commit b284495 (31 Oct 2016) by Dennis Kaarsemaker (seveas).
    See commit eef2bda (28 Oct 2016) by Junio C Hamano (gitster).
    (Merged by Junio C Hamano -- gitster -- in commit 6c18dd4, 27 Dec 2016)

    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.

提交回复
热议问题