logoalt Hacker News

joeyhyesterday at 2:34 PM0 repliesview on HN

Current branch without bloat is to cat .git/HEAD, and if that didn't exist, run git symbolic-ref HEAD. The first is faster and works in the common case where you're in the top of a git repo. In either case, run it through ${branch##*/} to strip down to just the current branch.

I have used this for a long time, never understood how people would put all of git in between them and the next prompt.