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

How to find the first commit belonging to any branch

From
KAKristian Amlie <kristian.amlie@trolltech.com>
Date
Jul 22, 2008, 09:08 UTC
Message-ID
<4885A39F.5080209@trolltech.com>
Hi all!

I have a question about git: I have one commit sha1, and I would like to know the nearest commit that appears in *any* other branch. The sha1 that I have does not belong to any branch.

The obvious thing to do would be to make a for loop and iterate over existing branches while calling git merge-base, but I'm wondering if there's a more clever method.

Regards Kristian Amlie

Next: Junio C Hamano
Message 1 of 3 in “How to find the first commit belonging to any branch”
  1. Kristian AmlieJul 22, 2008
  2. Junio C HamanoJul 22, 2008
  3. Kristian AmlieJul 22, 2008

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.