git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Getting the "message" given a branch designation and conversely

From
Jeff King <peff@peff.net>
Date
Aug 15, 2016, 12:28 UTC
Message-ID
<20160815122820.msajaamgmlexe2jd@sigill.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
Previous: Philip OakleyNext: Jakub Narębski
Message 3 of 4 in “Getting the "message" given a branch designation and conversely”
  1. norm@dad.orgAug 14, 2016
  2. Philip OakleyAug 14, 2016
  3. Jeff KingAug 15, 2016
  4. Jakub NarębskiAug 24, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.