threads / discuss / 30749

show refs points to a commit

Subject: show refs points to a commit

## tl;dr

5 messages between Jun 8, 2012 and Jun 8, 2012.

replies: 4people: 3as markdown or json

Ralf Thielow· Jun 8, 2012, 19:37 UTC · lore

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· Jun 8, 2012, 19:47 UTC · re: Ralf Thielow · lore

Re: show refs points to a commit

Op 8-6-2012 21:37, Ralf Thielow schreef:
Show 11 quoted lines
> 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· Jun 8, 2012, 19:51 UTC · re: Vincent van Ravesteijn · lore

Re: show refs points to a commit

On Fri, Jun 8, 2012 at 9:47 PM, Vincent van Ravesteijn <vfr@lyx.org> wrote:
Show 9 quoted lines
> 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· Jun 8, 2012, 20:03 UTC · re: Ralf Thielow · lore

Re: show refs points to a commit

Ralf Thielow <ralf.thielow@googlemail.com> writes:
Show 13 quoted lines
> 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· Jun 8, 2012, 20:10 UTC · re: Junio C Hamano · lore

Re: show refs points to a 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.

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

← back to recent threads