As of version 2.22 of git you could just use:
git branch --show-current
As per man page:
Print the name of the current branch. In detached HEAD state, nothing is printed.
As of version 2.22 of git you could just use:
git branch --show-current
As per man page:
Print the name of the current branch. In detached HEAD state, nothing is printed.