How do I get the current branch name in Git?

To display only the name of the current branch you’re on:

git rev-parse --abbrev-ref HEAD

Reference: Show just the current branch in Git

Leave a Comment