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

Re: Find the starting point of a local branch

From
Kevin <ikke@ikke.info>
Date
Dec 24, 2012, 09:12 UTC
Message-ID
<CAO54GHDPaBqLGV7nNS-fwMZV4t_XCfDA-tAx5w7SrWWsM+YBGA@mail.gmail.com>
In-Reply-To
<20121224073103.GA10793@zuhnb712>
On Mon, Dec 24, 2012 at 8:31 AM, Woody Wu <narkewoody@gmail.com> wrote:
> But thanks anyway, I see you guys's discussions and it's a little hard
> to understand to me at the moment. Currently, I still have to use gitk
> with narrowed outputs.

Each commit refers to it's parent. If you take a branch, and keep following the first parent of the commits, you will finally reach the root commit (the first commit made). You don't see any branches, it's just one straight line. That's why git can't tell you where a branch started, because it all looks like a single branch to git.

With merge-base, you basically give git two branches, and git finds the first ancestor that is common to both branches.

See [1] for an example. If you follow the arrows from branch a, you get from E to A (note that commit C doesn't know about commit F pointing to it). So it looks like there is only a single branch.

If you do git merge-base a b, git sees both branches have commit C in common, and reports that as the merge-base.

[1]: http://g.jk.gs/9W.png
Previous: Woody WuNext: Martin von Zweigbergk
Message 14 of 17 in “Find the starting point of a local branch”
  1. Woody WuDec 24, 2012
  2. Seth RobertsonDec 24, 2012
  3. Nguyen Thai Ngoc DuyDec 24, 2012
  4. Tomas CarneckyDec 24, 2012
  5. Nguyen Thai Ngoc DuyDec 24, 2012
  6. Junio C HamanoDec 24, 2012
  7. Nguyen Thai Ngoc DuyDec 24, 2012
  8. Junio C HamanoDec 24, 2012
  9. Nguyen Thai Ngoc DuyDec 25, 2012
  10. Jeff KingDec 24, 2012
  11. Nguyen Thai Ngoc DuyDec 24, 2012
  12. Jeff KingDec 24, 2012
  13. Woody WuDec 24, 2012
  14. KevinDec 24, 2012
  15. Martin von ZweigbergkDec 24, 2012
  16. Woody WuDec 28, 2012
  17. Martin von ZweigbergkDec 28, 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.