据我所知,我的 git 本地存储库中的所有内容都很好。我可以提交、 push 、 pull 任何我喜欢的东西。
但是,当我在 IntelliJ 日志中查看提交的详细信息时,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
这可能是什么原因造成的,我该如何解决?
最佳答案
origin/head
听起来像是在您的远程源 repo 中设置的默认分支。例如,当我做 git branch -a
,我看到这个出现在列表中:
remotes/origin/HEAD -> origin/master
如果远程中的默认分支发生更改,并且旧的默认分支已被删除,您可能会在本地存储库中丢失此引用,或者您的本地存储库的引用可能已过时。
可能的解决方案
如果这确实是您的 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
# Or shorter
git remote set-head <remote> -a
它是在 commit bc14fac 中介绍的用于 git 1.6.3(2009 年 5 月)。
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 fororigin
is set tomaster
, thenorigin
may be specified wherever you would normally specifyorigin/master
.
关于git - IntelliJ 错误 : branch 'origin/HEAD' does not point at a commit, 无法读取某些引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18570982/