git rev-parse --symbolic-full-name --abbrev-ref HEAD

Obtain the name of the current branch

This command is used to interpret the HEAD as a revision and print its name. It navigates the Git object database and returns the full symbolic name of the current branch.

The --symbolic-full-name flag tells git to treat the input as a refspec and resolve it to a fully qualified reference name (branch name). The --abbrev-ref flag abbreviates the full branch name to a human-friendly version.

Variations may include removal of these two flags which will result in printing just the commit hash, or using the --verify flag to check if the input is a valid revision.