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

Re: How to find where a branch was taken from.

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 21, 2008, 09:15 UTC
Message-ID
<7vzlssphdn.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<7v4pb0qw28.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 22 quoted lines
> Paul Gardiner <osronline@glidos.net> writes:
>
>> I need a command that will find the remote branch from which
>> the currently checked out branch was started. I don't know
>> git very well, and the only way I can think to do it so far
>> is to iterate over the remote branches and find the one
>> for which git-rev-list <branch>..HEAD gives the smallest
>> number of objects. I'm guessing there must be a better
>> way. Any ideas?
>
> There will be _no_ way.  It is simply impossible.
>
>     $ git checkout -b my-new-branch origin/somerandombranch~27^2^2~23
>
> is a perfectly valid way to create a new branch.
>
> You would probably want to re-think in a bigger picture, _why_
> you would want to find such information, in other words, how you would
> want to use the information (if such a thing were possible) to solve
> _what_ problem.  That true problem you did not mention (and assumed that
> "the remote branch the branch was branched from" would be a good tool to
> solve it) might have a better solution.
Having said that, have you tried:
	$ git reflog show that_local_branch
and looked for "branch: Created from blah"?
Previous: Junio C HamanoNext: Avery Pennarun
Message 3 of 12 in “How to find where a branch was taken from.”
  1. Paul GardinerMar 21, 2008
  2. Junio C HamanoMar 21, 2008
  3. Junio C HamanoMar 21, 2008
  4. Avery PennarunMar 21, 2008
  5. Charles BaileyMar 21, 2008
  6. Avery PennarunMar 21, 2008
  7. Dmitry PotapovMar 21, 2008
  8. Daniel BarkalowMar 21, 2008
  9. J. Bruce FieldsMar 21, 2008
  10. Paul GardinerMar 22, 2008
  11. Jeff KingMar 22, 2008
  12. Paul GardinerMar 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.