As mentioned here: http://stackoverflow.com/questions/6245570/get-current-branch-name, you can use `git rev-parse --abbrev-ref HEAD` or `git symbolic-ref --short HEAD` to get the branch name directly, without requiring any additional parsing.