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; }'
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; }'
I'm using
/etc/bash_completion.d/git
It came with git and provides a prompt with branch name and argument completion.
You may be interested in the output of
git symbolic-ref HEAD
In particular, depending on your needs and layout you may wish to do
basename $(git symbolic-ref HEAD)
or
git symbolic-ref HEAD | cut -d/ -f3-
and then again there is the .git/HEAD
file which may also be of interest for you.
$ git rev-parse --abbrev-ref HEAD
master
This should work with Git 1.6.3 or newer.