如何在 git 中让 Head 指向 master?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19335710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make Head point to master in git?
提问by zyxel
Please help to make Head point to master in git
请帮助在 git 中使 Head 指向 master
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.
新更新: remotes -> origin 中有 HEAD 分支。取出后一切正常。我不再有那个警告了。
回答by VonC
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 alsothe name of a branch:
但是,如果“ HEAD
”也是分支的名称:
- Don't do that.
HEAD
shouldn't be the name of a branch: rename it. You can try a:
git checkout master git merge HEAD
- 不要那样做。
HEAD
不应该是分支的名称:重命名它。 你可以试试:
git checkout master git merge HEAD
Which should fast-forward that branch to master
.
哪个应该将该分支快进到master
.
Actually, the OP confirms:
实际上,OP确认:
There was
HEAD
branch in remotes/origin.
After removing it everything is ok. I do not have that warning anymore.
HEAD
在遥控器/起源中有分支。
取出后一切正常。我不再有那个警告了。
Note this is different from origin/HEAD
, which identifies the default branch on that remote repository.
请注意,这是不同的origin/HEAD
,它标识在远程存储库的默认分支。