Git:refname'master'不明确 [英] Git: refname 'master' is ambiguous

查看:140
本文介绍了Git:refname'master'不明确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了所有其他模棱两可的refname问题,而且他们似乎都没有帮助。为什么我得到这个警告?

  $ git checkout master 
警告:refname'master'含糊不清。
$ git show-ref master
eef61c00da690f093063ac5a728e22fd21648104 refs / heads / master
$ git branch -a
跳棋
练习
* master
$ git remote -v
$


解决方案

DR:保存并删除标签,如 Ashutosh Jindal comments (参见

  git标签tag-master master 
git标签>在git中重命名标签? -d master






原始答案:



我看到的大部分来源(如此常见问题 a>)指向相同的原因:


当y ou尝试结帐本地分行,您会收到一个




 警告:refname'分行名称'是不明确的




如果您创建了一个与远程标签名称相同的本地分支

Git应该检出您的本地分支,但是它试图检出标签,并且会变得混乱。



几棵树的初始导入是有问题的,因为它们包含相同名称的分支和标签。此后,我们通过 重命名标签 即可。


在你的情况下,你没有远程的,但是像你的分支一样命名的本地标签就足够了。



不明确性在 gitrevision



< refname> ,例如主人首长/主人裁判/头/主人




符号参考名称。例如。 master 通常表示由 refs / heads / master 引用的提交对象。

如果您碰巧同时拥有标题/主标记标记/主标记,则可以明确指出头部/大师 来告诉git您的意思。
当含糊不清时,a < refname> 通过在以下规则中进行第一次匹配来消除歧义:

如果存在 $ GIT_DIR /< refname> 这就是你的意思(这通常只适用于 HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD CHERRY_PICK_HEAD );

否则, refs /< refname> 如果存在;

  • 否则, refs / tags /< refname> 如果存在;
  • 否则, refs / heads /< refname> 如果它存在;

  • 否则, refs / remotes /< refname> 存在;
  • 否则, refs / remotes /< refname> / HEAD


  • 因此,请检查您的回购库中 master 的位置。



    并且 git checkout heads / master 总能正常工作。

    警告:默认情况下,该分支采用分离头模式。请参阅为什么 git checkout 具有显式的< refs /头部/分支'给分离的HEAD?



    为了避免这种情况,仍然使用明确的ref,请输入:

      git checkout -B master / master 


    I've looked at all of the other ambiguous refname questions and none of them seem to help. Why am I getting this warning?

    $ git checkout master
    warning: refname 'master' is ambiguous.
    $ git show-ref master
    eef61c00da690f093063ac5a728e22fd21648104 refs/heads/master
    $ git branch -a
      checkers
      exercises
    * master
    $ git remote -v
    $ 
    

    解决方案

    TL;DR: save and delete the tag, as Ashutosh Jindal comments (see "Rename a tag in git?"):

    git tag tag-master master
    git tag -d master
    


    Original answer:

    Most of the sources I see (like this FAQ) point to the same cause:

    When you try to checkout a local branch, you get a

    warning: refname 'branch-name' is ambiguous
    

    This can happen if you've created a local branch with the same name as a remote tag.
    Git should be checking out your local branch, but instead it's trying to checkout the tag, and it gets confused.

    The initial import of several trees were problematic, since they contained identically named branches and tags. We have since addressed a lot of these issues, by renaming away the tags.

    In your case, you don't have a remote, but local tags named like your branch could be enough.

    The ambiguity is specified in gitrevision

    <refname>, e.g. master, heads/master, refs/heads/master

    A symbolic ref name. E.g. master typically means the commit object referenced by refs/heads/master.
    If you happen to have both heads/master and tags/master, you can explicitly say heads/master to tell git which one you mean.
    When ambiguous, a <refname> is disambiguated by taking the first match in the following rules:

    If $GIT_DIR/<refname> exists, that is what you mean (this is usually useful only for HEAD, FETCH_HEAD, ORIG_HEAD, MERGE_HEAD and CHERRY_PICK_HEAD);

    • otherwise, refs/<refname> if it exists;
    • otherwise, refs/tags/<refname> if it exists;
    • otherwise, refs/heads/<refname> if it exists;
    • otherwise, refs/remotes/<refname> if it exists;
    • otherwise, refs/remotes/<refname>/HEAD if it exists.

    So check where master can be found in your repo.

    And git checkout heads/master would always work.
    Warning: by default, this would checkout the branch in a DETACHED HEAD mode. See "Why does git checkout with explicit 'refs/heads/branch' give detached HEAD?".

    To avoid that, and still use an unambiguous ref, type:

    git checkout -B master heads/master
    

    这篇关于Git:refname'master'不明确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆