Show just the current branch in Git

Question

Is there a Git command equivalent to:

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

Answer

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

This should work with Git 1.6.3 or newer.

How to show the first commit by 'git log'?

Remove credentials from Git