Thread (5 messages) flat view 5 messages, 5 authors, 2016-06-15

Re: git-branch --print-current

From: David Aguilar <hidden>
Date: 2016-06-15 22:45:51

On Thu, Jan 1, 2009 at 7:28 PM, Karl Chen [off-list ref] wrote:
How about an option to git-branch that just prints the name of
the current branch for scripts' sake?  To replace:

   git branch --no-color 2>/dev/null | perl -ne '/^[*] (.*)/ && print $1'

The justification I've heard before is that 'git branch' is a
porcelain and thus we shouldn't rely on its output for scripting
purposes.

You might want to use 'git symbolic-ref' instead.

$ git symbolic-ref HEAD
refs/heads/master

$ git symbolic-ref HEAD | sed -e 's,refs/heads/,,'
master


-- 
    David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help