10. HEAD can point at a commit with no note
HEAD can point straight at a commit; commits made there belong to no branch and will be collected unless a branch or tag is placed on them.

10. HEAD can point at a commit with no note

HEAD can point straight at a commit; commits made there belong to no branch and will be collected unless a branch or tag is placed on them.

The detached HEAD warning scares people into losing work or avoiding useful checkouts.

HEAD usually points at a branch. It can also point straight at a commit.

Check out an old commit, and that is what happens. Git calls it a detached HEAD.

Looking around is fine. Build it, run it, read it.

Commit here, and the new commit has no branch. Only HEAD points at it. Move HEAD away, and no note does.

To keep that work, make a branch before you leave. A note on the commit keeps it.

Check yourself. You committed in detached HEAD and want to keep it. What do you do before switching away?

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Collaborators