I need a git command that returns the name of the branch to which HEAD points. I.e., when I am on master, it should return master. In detached HEAD state, it can return either nothing or something that I will not confuse with a branch name. What is the easiest command to achieve this?
(Sorry, the question seems to be rather trivial and was probably asked a gazillion of times, but searching for things like "get branch to which HEAD points" didn't give me a satisfying result.)
 
     
    