git rev-parse

Display metadata related to revisions. More information: https://git-scm.com/docs/git-rev-parse.

git rev-parse branch_name

git rev-parse --abbrev-ref HEAD

git rev-parse --show-toplevel