Re: git-branch --print-current
- From
David Aguilar <davvid@gmail.com>
- Date
- Jan 2, 2009, 04:26 UTC
- Message-ID
- <402731c90901012026j470f35ffj1eaa189a837054f3@mail.gmail.com>
- In-Reply-To
- <quack.20090101T1928.lthzliaqtdf@roar.cs.berkeley.edu>
On Thu, Jan 1, 2009 at 7:28 PM, Karl Chen <quarl@cs.berkeley.edu> wrote:
Show 5 quoted lines
> > 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