# Getting the "message" given a branch designation and conversely

4 messages from 2016-08-14 to 2016-08-24. Participants: norm@dad.org, Philip Oakley, Jeff King, Jakub Narębski.
Thread: https://gitlist.dev/t/43840

## norm@dad.org, 2016-08-14 14:58

Subject: Getting the "message" given a branch designation and conversely
Message-ID: <201608141458.u7EEwF8P099500@shell1.rawbw.com>
URL: https://gitlist.dev/e/201608141458.u7EEwF8P099500%40shell1.rawbw.com

```
I am learning how to use git. I would like to know how:

Given a branch's designation, such as "master~4", how can I see the message I
furnished when I created the branch using "git commit"?

Conversely, given the message I furnished to "git commit", when I created a
branch, how can I see the branch's designation?

Context:

    Operating System: Red Hat Enterprise Linux Workstation release 6.8

    git version: 1.7.1

Thank you, very much.

    Norman Shapiro

```

## Philip Oakley, 2016-08-14 17:32

Subject: Re: Getting the "message" given a branch designation and conversely
Message-ID: <4B56CDE3883A4341994E6382DF68C438@PhilipOakley>
URL: https://gitlist.dev/e/4B56CDE3883A4341994E6382DF68C438%40PhilipOakley
In-Reply-To: <201608141458.u7EEwF8P099500@shell1.rawbw.com>

```
From: <norm@dad.org>
>I am learning how to use git. I would like to know how:
>
> Given a branch's designation, such as "master~4", how can I see the 
> message I
> furnished when I created the branch using "git commit"?
>
> Conversely, given the message I furnished to "git commit", when I created 
> a
> branch, how can I see the branch's designation?
>
> Context:
>
>    Operating System: Red Hat Enterprise Linux Workstation release 6.8
>
>    git version: 1.7.1
>
> Thank you, very much.
>
>    Norman Shapiro
> --

Norman,

To see the commit message try 'git log'. You will need a revision range, so 
try 'git help revisions' to set a guide about all the different ways you can 
spell that. While at it, it's worth 'git help glossary' just to understand 
some of the terminology.

--
Philip
'git log HEAD~4^!' 


```

## Jeff King, 2016-08-15 12:28

Subject: Re: Getting the "message" given a branch designation and conversely
Message-ID: <20160815122820.msajaamgmlexe2jd@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20160815122820.msajaamgmlexe2jd%40sigill.intra.peff.net
In-Reply-To: <201608141458.u7EEwF8P099500@shell1.rawbw.com>

```
On Sun, Aug 14, 2016 at 07:58:14AM -0700, norm@dad.org wrote:

> I am learning how to use git. I would like to know how:
> 
> Given a branch's designation, such as "master~4", how can I see the message I
> furnished when I created the branch using "git commit"?

Somebody already pointed you at "git log", which is the right tool for
looking at commit messages (or perhaps "git show" if you only want to
see a single entry).

> Conversely, given the message I furnished to "git commit", when I created a
> branch, how can I see the branch's designation?

Try "git log --grep=some.regex" to find a particular commit. Usually we
refer to commits by their sha1 id, which will be shown by git-log.
However, you can use git-describe to generate a name for any commit that
is based on traversing from a tag. Try:

  git describe --contains --all <sha1>

for example. Using "--all" tells git to consider names based on branches
as well as tags. Using "--contains" will generate a name based on
traversing backwards from the tags and branches (like "master~4") rather
than basing the name on a tag that you build off of.

-Peff

```

## Jakub Narębski, 2016-08-24 14:39

Subject: Re: Getting the "message" given a branch designation and conversely
Message-ID: <d75b165c-0b68-bd8e-31c0-cf7e704d6e61@gmail.com>
URL: https://gitlist.dev/e/d75b165c-0b68-bd8e-31c0-cf7e704d6e61%40gmail.com
In-Reply-To: <20160815122820.msajaamgmlexe2jd@sigill.intra.peff.net>

```
W dniu 15.08.2016 o 14:28, Jeff King pisze:
> On Sun, Aug 14, 2016 at 07:58:14AM -0700, norm@dad.org wrote:
> 
>> I am learning how to use git. I would like to know how:
>>
>> Given a branch's designation, such as "master~4", how can I see the message I
>> furnished when I created the branch using "git commit"?
> 
> Somebody already pointed you at "git log", which is the right tool for
> looking at commit messages (or perhaps "git show" if you only want to
> see a single entry).

I think you would want "git log -1 master~4" or "git show master~4" to
see the commit message of a single commit (without diff).

>> Conversely, given the message I furnished to "git commit", when I created a
>> branch, how can I see the branch's designation?
> 
> Try "git log --grep=some.regex" to find a particular commit. Usually we
> refer to commits by their sha1 id, which will be shown by git-log.

There is also :/<search> and <rev>^{/<search>} syntax, if you want 
composability (see gitrevisions(7)).

> However, you can use git-describe to generate a name for any commit that
> is based on traversing from a tag. Try:
> 
>   git describe --contains --all <sha1>
> 
> for example. Using "--all" tells git to consider names based on branches
> as well as tags. Using "--contains" will generate a name based on
> traversing backwards from the tags and branches (like "master~4") rather
> than basing the name on a tag that you build off of.

The "git describe --contains" is interface to "git name-rev" plumbing

-- 
Jakub Narębski


```
