Git问题(HEAD指向未出生的分支(主节点)) [英] Issues with Git (HEAD points to an unborn branch (master))

查看:197
本文介绍了Git问题(HEAD指向未出生的分支(主节点))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有'master'分支的Git存储库. 前一段时间(几个月),我们停止使用master,并创建了一个新分支,所有工作都在此完成.

I have a Git repository with 'master' branch. Some time ago (few months), we stopped using master, and created a new branch that all work is being done on.

我现在正在使用git设置源索引,由于某种原因,我在新分支中看到了奇怪的东西:

I am now setting up source indexing with git, and for some reason i am seeing weird stuff with the new branch:

  1. 运行 git log 失败:

致命:默认版本"HEAD"错误

fatal: bad default revision 'HEAD'

  • 运行 git fsck 会导致以下结果:

  • Running git fsck results in this:

    通知:HEAD指向未出生的分支(主)通知:无默认值 引用悬空提交81f11e0b99ad38ecc8502bbed171d2bdfcaa6476

    notice: HEAD points to an unborn branch (master) notice: No default references dangling commit 81f11e0b99ad38ecc8502bbed171d2bdfcaa6476

  • 我认为此存储库/分支不正确,这会导致源索引脚本出现问题.

    I think that something is not right with this repository/branch which is causing problems with the source indexing scripts.

    有什么想法吗? (请注意,这里的真正问题是源索引脚本无法获取它尝试使用git show查找的对象ID,它表示不存在此类对象.)

    Any ideas? (Note that the REAL issue here is that the source indexing script fails to get the object id it is trying to lookup using git show, it says that no such object exists).

    推荐答案

    您不必具有master分支,但必须在任何git存储库中都具有"default"分支.在非裸仓库中,这是检出的分支;在裸仓库中,这仅表示它是检出克隆的默认分支.

    You don't have to have a master branch but you do have to have a "default" branch in any git repository. In a non-bare repository this the checked out branch, in a bare repository it just means it's the default branch checked out for clones.

    此默认分支称为HEAD,并且必须始终存在于有效的git存储库中.如果您删除了HEAD指向的分支,则可以使用以下命令将其重置为有效分支:

    This default branch is called HEAD and must always exist in a valid git repository. If you've removed the branch that HEAD was pointing at you can reset to a valid branch it with:

    git symbolic-ref HEAD refs/heads/new-main-branch
    

    这篇关于Git问题(HEAD指向未出生的分支(主节点))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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