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

Answer by MerickOWA for How do I get the current branch name in Git?

$
0
0

If you're using a detached HEAD but there is a branch pointing to the same commit as HEAD, here was the only method I found that would work to find a branch and properly ignore tags.

git for-each-ref --format="%(refname:short)" --points-at HEAD refs/heads

The refs/heads filter is to only list local branches, and excludes remote branches as well as any tags.


Viewing all articles
Browse latest Browse all 96

Trending Articles