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

Re: How can i find the origin of a branch?

From
Alex Riesen <raa.lkml@gmail.com>
Date
Jun 15, 2009, 12:07 UTC
Message-ID
<81b0412b0906150507r7b141951w7246b0abab9624e2@mail.gmail.com>
In-Reply-To
<2f3bf9a60906150437v765c2cecva61307ae9cf0cec7@mail.gmail.com>
2009/6/15 Dotan Barak <dotanba@gmail.com>:
> Is it possible to find the origin of a branch?
> (the remote repository that this branch was cloned and checked out from)

Look for a repository which has the smallest count of commits in common with the branch.

You can use git merge-base to find all the commits which could possible be the point of divergence (aka "merge base"). Then you can find all the remote branches which have the "merge bases" (git branch --contains <base>). Any of that remote branches could have been the origin of your local branch.

You'll seldom (if ever again) need that, I think.

P.S. You don't clone branches. Not as such. You clone repositories, which have the commits, which a branch (as in "reference") can point to.

Previous: Kristian Amlie
Message 7 of 7 in “How can i find the origin of a branch?”
  1. Dotan BarakJun 15, 2009
  2. Kristian AmlieJun 15, 2009
  3. Dotan BarakJun 15, 2009
  4. Dotan BarakJun 15, 2009
  5. Alex RiesenJun 15, 2009
  6. Kristian AmlieJun 15, 2009
  7. Alex RiesenJun 15, 2009

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.