简体   繁体   English

Git 创建分离 HEAD 所在的分支

[英]Git create branch where detached HEAD is

I tried something like this:我试过这样的事情:

git branch temp

to create a new branch but don't move the HEAD .创建一个新分支但不要移动HEAD But I get:但我得到:

# Not currently on any branch.

I don't want to merge anything, I just want a new branch at the current HEAD .我不想合并任何东西,我只想在当前HEAD建立一个新分支。

You're sitting on a detached HEAD : 你正坐在一个独立的HEAD

git checkout <sha>

You want to make a branch at that commit: 你想在那个提交上做一个分支:

git branch my-new-branch

And now switch to that branch: 现在转到那个分支:

git checkout my-new-branch

您还可以使用:

git switch -c <new branch name>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM