$ git checkout -b foo # or "git switch -c foo" (1) $ git branch foo (2) $ git tag foo (3) creates a new branch foo , which refers to commit f , and then updates HEAD to refer to branch foo . In other words, we’ll no longer be in detached HEAD state after this command.