IntelliJ错误:分支'origin / HEAD'不指向提交,有些引用无法读取 [英] IntelliJ error: branch 'origin/HEAD' does not point at a commit, some refs could not be read

查看:711
本文介绍了IntelliJ错误:分支'origin / HEAD'不指向提交,有些引用无法读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我可以告诉我的git本地存储库中的所有内容都很好。我可以提交,推,拉,不管我喜欢什么。



然而,当我在IntelliJ日志中查看提交的细节时, Contained在分支中:

 由于错误,无法加载分支:
错误: origin / HEAD'不指向提交
错误:某些ref不能被读取
错误:branch'origin / HEAD'不指向提交
错误:某些refs不能被读为

导致这种情况的原因是什么?如何解决?

解决方案

origin / head 听起来像是指您远程原点回购中设置的默认分支。例如,当我做 git branch -a 时,我看到这个显示在列表中:

  remotes / origin / HEAD  - >您可能会在您的本地回购中缺少此参考,或者您的本地回购参考可能是您的本地回购过期,如果默认分支在远程被更改,旧的默认被删除。



可能的解决方案



如果这确实是您的IDE错误的原因,那么您可以使用 git symbolic-ref 手动更正它:

  git symbolic-ref refs / remotes / origin / HEAD refs / remotes / origin /< default-branch> 

其中< default-branch> 是该分支在您的远程仓库中是默认的。



更新解决方案



所以git实际上有一个更方便的命令它可以用来更新本地仓库的符号引用到远程仓库的默认分支:

  git remote set-head< remote> --auto 

#或更短
git远程设置头<远程> -a




  • git remote set-head 的文档。

  • $ b


    设置或删除默认分支( $ GIT_DIR / remotes /< name> / HEAD )为
    指定的远程服务器。
    为远程不需要,但允许指定远程名称来代替特定的分支。

    例如,如果 origin的默认分支设置为 master ,则可以指定 origin > origin / master



    As far as I can tell everything in my git local repository is fine. I can commit, push, pull, whatever I like.

    However, when I view the details of a commit in the IntelliJ log, the Contained in branches:

    Can not load branches due to error:
    error: branch 'origin/HEAD' does not point at a commit 
    error: some refs could not be read 
    error: branch 'origin/HEAD' does not point at a commit 
    error: some refs could not be read
    

    What could have caused this and how do I fix it?

    解决方案

    origin/head sounds like it refers to the default branch set in your remote origin repo. For example, when I do git branch -a, I see this show up in the list:

    remotes/origin/HEAD -> origin/master
    

    You might be missing this reference in your local repo, or your local repo's reference might be out of date, if the default branch is changed in the remote, and the old default is deleted.

    Possible Solution

    If this is indeed the cause of your IDE error, then you can manually correct it using git symbolic-ref:

    git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/<default-branch>
    

    Where <default-branch> is the branch that is default in your remote repo.

    Updated Solution

    So git actually has a more convenient command that can be used to update a local repo's symbolic-ref to the default branch in a remote repo:

    git remote set-head <remote> --auto
    
    # Or shorter
    git remote set-head <remote> -a
    

    It was introduced in commit bc14fac for git 1.6.3 (May 2009).

    Sets or deletes the default branch ($GIT_DIR/remotes/<name>/HEAD) for the named remote.
    Having a default branch for a remote is not required, but allows the name of the remote to be specified in lieu of a specific branch.
    For example, if the default branch for origin is set to master, then origin may be specified wherever you would normally specify origin/master.

    这篇关于IntelliJ错误:分支'origin / HEAD'不指向提交,有些引用无法读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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