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

Finding a branch point in git

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 27, 2012, 12:37 UTC
Message-ID
<CAMP44s0f7AJPQSTDgvy0U7vx8nxzq2a3vMhSr2Tcc61fetFkJA@mail.gmail.com>
Hi,

When discussing git vs. mercurial, and what can mercurial do that git can't, I inevitably see somebody mention that mercurial branches can be used to find the branch point (the point at which a branch started; even if it's a long-lived one that has been merged to 'master' multiple times).

There have been a few solutions in stackoverflow[1], but none that work in all cases.

But I think I've found an ad-hoc one that uses the commit messages to find the first merge of a branch, and then the merge-base.

For reference, if somebody is interested:
---
[alias]
    branch-point = !sh -c 'merge=$(git rev-list --min-parents=2
--grep="Merge.*$1" --all | tail -1) && git merge-base $merge^1
$merge^2'
---
Cheers.
[1] http://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git/
-- 
Felipe Contreras
Next: Jeff King
Message 1 of 13 in “Finding a branch point in git”
  1. Felipe ContrerasMay 27, 2012
  2. Jeff KingMay 28, 2012
  3. Felipe ContrerasMay 28, 2012
  4. Jeff KingMay 28, 2012
  5. Felipe ContrerasMay 30, 2012
  6. Jeff KingMay 30, 2012
  7. Felipe ContrerasMay 31, 2012
  8. Felipe ContrerasMay 31, 2012
  9. PJ WeisbergMay 31, 2012
  10. Felipe ContrerasJun 1, 2012
  11. Martin LanghoffMay 31, 2012
  12. Felipe ContrerasMay 30, 2012
  13. Jeff KingMay 30, 2012

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.