Git:警告:refname'master'含糊不清 [英] Git: warning: refname 'master' is ambiguous

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

问题描述

我看到有几个人在这里问同样的问题,但似乎他们的任何建议都不适用于我。我收到了这个标题中的警告,但是我没有任何标签名为master。这是 git branch -a 的结果:

  * master 
remotes / origin / HEAD - >原产地/主人
遥控器/原产地/主人

有什么想法可能会出错?我只用了几个月的时间,所以大多数时候我只是担心这个歧义可能会在将来的repo中混乱。

解决方案

对于我来说,当我错误地发出update-ref命令时,我更早地追踪了此警告的来源。如果您忘记在第一个参数中指定完整的refs / heads / mybranchname路径,则会创建一个文件.git / mybranchname,当您尝试切换到该分支时,会导致此警告。



它通过简单地删除.git / mybranchname来解决,例如:

  rm .git / master 

作为参考,update-ref命令的正确格式为:

  git update-ref refs / heads / mybranchname mytargetbranch 

不要忘记refs / heads部分!

另外,我最常用的update-ref用法很简单移动分支指向另一个提交,我发现了一个更简单的语法:
$ b $ git branch -f myBranchToMove destinationBranchOrHash c $ c
$ b

这个语法对我来说比较容易,因为它不需要易错的refs / heads路径限定符。


I saw a few people asking the same question on here but it seems none of their advice is applicable to me. I'm getting the warning that is in the title of this but I don't have any tags named "master". This is the result of git branch -a:

* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

Any idea what could be going wrong here? I've only been using git for a few months now, so it mostly just worries me that this ambiguity might mess with the repo in the future.

解决方案

For me I tracked down the source of this warning to much earlier when I incorrectly issued an "update-ref" command. If you forget to specify the full refs/heads/mybranchname path in the first arg, then a file .git/mybranchname gets created, which later leads to this warning when you try to switch to that branch.

It is solved by simply deleting the .git/mybranchname, eg:

rm .git/master

And for reference, the correct form for the update-ref command is:

git update-ref refs/heads/mybranchname mytargetbranch

Don't forget the "refs/heads" part!

Also, my most common use-case for update-ref is simply manually moving a branch to point to another commit, which I've found a simpler syntax to do:

git branch -f myBranchToMove destinationBranchOrHash

This syntax is easier for me because it doesn't require that error-prone refs/heads path qualifier.

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

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