How to name a (no branch)-branch on git

git, git-branch

Solution

"no branch" is not a branch, as the name says. It means you have checked out a revision that isn't the tip of a branch.

To create a branch of it, simply

git checkout -b extraBranchIEndedUpWith

Just like you would create any other branch from your current revision.

Problem

It happened somehow that I left the `master` branch and ended up on the `no branch` branch. How can I give this branch a meaningful name? In detail: Calling `git branch` shows ``` * (no branch) master ``` and what I want (without changing any file) is to have e.g. ``` * extraBranchIEndedUpWith master ``` `git status` is clean.

Original source