我看到有几个人在这里问同样的问题,但似乎他们的任何建议都不适用于我。我收到了这个标题中的警告,但是我没有任何标签名为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/masterAny 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/masterAnd for reference, the correct form for the update-ref command is:
git update-ref refs/heads/mybranchname mytargetbranchDon'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'含糊不清
发布评论