Git create branch where detached HEAD is

Solution 1:

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

Solution 2:

You can also use:

git switch -c <new branch name>