Show just the current branch in Git

Ollie Saunders picture Ollie Saunders · Sep 13, 2009 · Viewed 138.5k times · Source

I tried looking for a special Git command for this, but I couldn't find one. Is there anything shorter or faster than the following?

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

Answer

earl picture earl · Sep 13, 2009
$ git rev-parse --abbrev-ref HEAD
master

This should work with Git 1.6.3 or newer.