Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show just the current branch in Git

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; }' 
like image 547
Ollie Saunders Avatar asked Sep 13 '09 15:09

Ollie Saunders


People also ask

How do I checkout the latest branch?

In order to checkout a new branch from a specific start point, you have to execute the “git checkout” command and specify the “-B” option, as well as the branch and its start point.


1 Answers

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

This should work with Git 1.6.3 or newer.

like image 78
earl Avatar answered Sep 30 '22 11:09

earl