bjjqzg
Last Updated: February 25, 2016
·
412
· colindean
E3c791e8e5da39bf88b09dfb089de01b

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
Say Thanks
Respond

4 Responses
Add your response

15477
23e8d9c545b0a9d603765abaadc3f499

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
26512eadc52f8e2257ac789bbd4a1a39

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

over 1 year ago ·
15509
Devdungeon avatar

I just type

git branch

over 1 year ago ·
15513
Photo

too

over 1 year ago ·
Filed Under

Awesome Job

E20ce6a2 ca1f 11e7 82be 7f617c8310c9
SENIOR DEVELOPER (m/w)
·
Berlin, Köln, Hamburg, München
·
Full Time