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

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

$
0
0

If you really want the last branch/tag checked out in detached HEAD state as well.

git reflog HEAD | grep 'checkout:' | head -1 | rev | cut -d'' -f1 | rev

UpdateThis is nicer if you have and aren't scared of awk.

git reflog HEAD | grep 'checkout:' | head -1 | awk '{print $NF}'

Viewing all articles
Browse latest Browse all 96

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>