简体   繁体   中英

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 . 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 .

You're sitting on a detached 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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