Quantcast
Channel: How do I get the current branch name in Git? - Stack Overflow
Viewing all articles
Browse latest Browse all 96

Answer by user for How to get the current branch name in Git?

$
0
0

Returns either branch name or SHA1 when on detached head:

git rev-parse --abbrev-ref HEAD | grep -v ^HEAD$ || git rev-parse HEAD

This is a short version of @dmaestro12's answer and without tag support.


Viewing all articles
Browse latest Browse all 96

Trending Articles