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

前端 未结 1 1714
庸人自扰
庸人自扰 2021-01-11 17:46

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 In

相关标签:
1条回答
  • 2021-01-11 18:02

    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
    
    • Documentation for git remote set-head.

    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.

    0 讨论(0)
提交回复
热议问题