# show refs points to a commit

5 messages from 2012-06-08 to 2012-06-08. Participants: Ralf Thielow, Vincent van Ravesteijn, Junio C Hamano.
Thread: https://gitlist.dev/t/30749

## Ralf Thielow, 2012-06-08 19:37

Subject: show refs points to a commit
Message-ID: <CAN0XMO+G6K0FZgu35OuuqGEp322vLpakXHXBTPpUQmoex68srA@mail.gmail.com>
URL: https://gitlist.dev/e/CAN0XMO%2BG6K0FZgu35OuuqGEp322vLpakXHXBTPpUQmoex68srA%40mail.gmail.com

```
After playing around with submodules, I haven't
found a builtin way to show refs pointing to a
specified commit without using UNIX pipes.

Especially when you working with submodules, it
would be very helpful to know which refs
points to this commit in order to switch from
"detached HEAD" to the branch you can (maybe)
work with.

Or did I miss something?

Thanks

Ralf

```

## Vincent van Ravesteijn, 2012-06-08 19:47

Subject: Re: show refs points to a commit
Message-ID: <4FD256CC.5010801@lyx.org>
URL: https://gitlist.dev/e/4FD256CC.5010801%40lyx.org
In-Reply-To: <CAN0XMO+G6K0FZgu35OuuqGEp322vLpakXHXBTPpUQmoex68srA@mail.gmail.com>

```
Op 8-6-2012 21:37, Ralf Thielow schreef:
> After playing around with submodules, I haven't
> found a builtin way to show refs pointing to a
> specified commit without using UNIX pipes.
>
> Especially when you working with submodules, it
> would be very helpful to know which refs
> points to this commit in order to switch from
> "detached HEAD" to the branch you can (maybe)
> work with.
>
> Or did I miss something?

Is this what you mean ?

$ git rev-parse master
f623ca1cae600e97cb0b38131fdd33e4fb669cf8
$ git name-rev f623ca1cae600
f623ca1cae600 master
$ git name-rev --refs=refs/heads/* f344333cd
f344333cd master~10

Vincent

```

## Ralf Thielow, 2012-06-08 19:51

Subject: Re: show refs points to a commit
Message-ID: <CAN0XMO+FpCWgf96ffZ0qd7TNEmdBXicvvk23fnXBaTK_7weV-g@mail.gmail.com>
URL: https://gitlist.dev/e/CAN0XMO%2BFpCWgf96ffZ0qd7TNEmdBXicvvk23fnXBaTK_7weV-g%40mail.gmail.com
In-Reply-To: <4FD256CC.5010801@lyx.org>

```
On Fri, Jun 8, 2012 at 9:47 PM, Vincent van Ravesteijn <vfr@lyx.org> wrote:
> Is this what you mean ?
>
> $ git rev-parse master
> f623ca1cae600e97cb0b38131fdd33e4fb669cf8
> $ git name-rev f623ca1cae600
> f623ca1cae600 master
> $ git name-rev --refs=refs/heads/* f344333cd
> f344333cd master~10
>

I just want to know what's the refs where
the *tip* points to my specified commit.

```

## Junio C Hamano, 2012-06-08 20:03

Subject: Re: show refs points to a commit
Message-ID: <7v4nqld11k.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v4nqld11k.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAN0XMO+FpCWgf96ffZ0qd7TNEmdBXicvvk23fnXBaTK_7weV-g@mail.gmail.com>

```
Ralf Thielow <ralf.thielow@googlemail.com> writes:

> On Fri, Jun 8, 2012 at 9:47 PM, Vincent van Ravesteijn <vfr@lyx.org> wrote:
>> Is this what you mean ?
>>
>> $ git rev-parse master
>> f623ca1cae600e97cb0b38131fdd33e4fb669cf8
>> $ git name-rev f623ca1cae600
>> f623ca1cae600 master
>> $ git name-rev --refs=refs/heads/* f344333cd
>> f344333cd master~10
>>
>
> I just want to know what's the refs where
> the *tip* points to my specified commit.

"git for-each-ref" gives the mapping from the tip of your refs to
object names.  We do not keep and give reverse mapping but there
should be enough information in for-each-refs output to get the
information yourself, I think.

```

## Ralf Thielow, 2012-06-08 20:10

Subject: Re: show refs points to a commit
Message-ID: <CAN0XMOK=KwHSc0oZZJYBSmqYLG31W0vcA=Qt929uCf7PHsuqiw@mail.gmail.com>
URL: https://gitlist.dev/e/CAN0XMOK%3DKwHSc0oZZJYBSmqYLG31W0vcA%3DQt929uCf7PHsuqiw%40mail.gmail.com
In-Reply-To: <7v4nqld11k.fsf@alter.siamese.dyndns.org>

```
> "git for-each-ref" gives the mapping from the tip of your refs to
> object names.  We do not keep and give reverse mapping but there
> should be enough information in for-each-refs output to get the
> information yourself, I think.

But you need to grep if you have a big list, don't you?
Michael H. points me to: "git log -1 --decorate"
which works very well to me.

Thanks

```
