Re: v2.9.3 and v2.10.0: `name-ref' HEAD gives wrong branch name
- From
Bryan Turner <bturner@atlassian.com>
- Date
- Sep 20, 2016, 18:54 UTC
- Message-ID
- <CAGyf7-FR11Ludt3vNZX7Ek4n_JLSON5+Y9By83GvNgpg94TWcg@mail.gmail.com>
- In-Reply-To
- <20160920162309.l0neYMQ3l%steffen@sdaoden.eu>
On Tue, Sep 20, 2016 at 9:23 AM, Steffen Nurpmeso <steffen@sdaoden.eu> wrote:
Show 16 quoted lines
> Hello again, > > yah, sorry, i'm back again.. > I try to find a way to find the name of the current branch in an > automated way, because i need to ensure that a commit happens on > it and no other branch. Now the problem arises that the commit > ref at the time of that commit maybe shared in between several > different branches, but no more thereafter, of course: > > ?0[steffen@wales ]$ git branch|grep '^*' > * stable/v14.9 > ?0[steffen@wales ]$ git name-rev --name-only HEAD > stable/v14.8 > > Is there another way except looking into .git/HEAD or using sed(1) > on the output of `branch' to find the right name?
Have you tried "git symbolic-ref HEAD"?
$ git symbolic-ref HEAD refs/heads/master
If you don't want the fully-qualified ref, you can add --short:
$ git symbolic-ref --short HEAD master
> Thank you. > Ciao! > > --steffen