[Git] Get the current branch name as plain text

Created on November 30, 2026

Use git rev-parse --abbrev-ref HEAD to display the current branch name without the leading asterisk shown by git branch. In a detached HEAD state, this command prints HEAD.

git rev-parse --abbrev-ref HEAD
Git