Ollie Saunders Ollie Saunders - 29 days ago 11
Git Question

Show just the current branch in Git

I tried looking for a special git command for this but couldn't find one. Can anyone suggest anything shorter or faster than:

git branch | awk '/\*/ { print $2; }'

Answer Source
$ git rev-parse --abbrev-ref HEAD
master

This should work with Git 1.6.3 or newer.