bjjqzg
Last Updated: February 25, 2016
·
437
· colindean

Get the current git branch

git
git symbolic-ref --short -q HEAD

Remove --short and you'll get the full one, e.g. ref/heads/master.

This is even more useful when added as an alias in your ~/.gitconfig:

[alias]
  current-branch = symbolic-ref --short -q HEAD

4 Responses
Add your response

15477

The option --short is not available on git version 1.7.1 (which is the default for many RHEL based systems outhere (CentOS 6 etc...).

over 1 year ago ·
15508

oh-my-zsh git plugin is super productive! check it out.

over 1 year ago ·
15509

I just type

git branch

over 1 year ago ·
15513

too

over 1 year ago ·
Filed Under