How to make Head point to master in git?

青春壹個敷衍的年華 提交于 2019-12-10 03:59:44

问题


Please help to make Head point to master in git

I tried to

git rebase HEAD master

and

git checkout master

Nothing of those helps.

Updated: Strange I tried:

git symbolic-ref HEAD
refs/heads/master

then

git rev-parse refs/heads/master
fc550e5ff2fe49d64ee1d8bf0da09b2b24bf2cd7

and then I got strange warning after the following command

git rev-parse HEAD
warning: refname 'HEAD' is ambiguous.
fc550e5ff2fe49d64ee1d8bf0da09b2b24bf2cd7

New Update: There was HEAD branch in remotes -> origin . After removing it everything is ok. I do not have that warning anymore.


回答1:


IF you don't have any local work in progress:

git checkout master
git reset --hard     # reset HEAD to the master branch

But, if 'HEAD' is also the name of a branch:

  1. Don't do that. HEAD shouldn't be the name of a branch: rename it.
  2. You can try a:

    git checkout master
    git merge HEAD
    

Which should fast-forward that branch to master.


Actually, the OP confirms:

There was HEAD branch in remotes/origin.
After removing it everything is ok. I do not have that warning anymore.

Note this is different from origin/HEAD, which identifies the default branch on that remote repository.



来源:https://stackoverflow.com/questions/19335710/how-to-make-head-point-to-master-in-git

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