Use git branch --contains HEAD | tail -1 | xargs
it also works for "detached HEAD" state.
↧
Answer by glisu for How to get the current branch name in Git?
↧
Use git branch --contains HEAD | tail -1 | xargs
it also works for "detached HEAD" state.