IntelliJ error: branch 'origin/HEAD' does not point at a commit, some refs could not be read

匿名 (未验证) 提交于 2019-12-03 02:24:01

问题:

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?

回答1:

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.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!