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

Re: Find the starting point of a local branch

From
Jeff King <peff@peff.net>
Date
Dec 24, 2012, 06:19 UTC
Message-ID
<20121224061938.GA25186@sigill.intra.peff.net>
In-Reply-To
<CACsJy8CNd3W_WUMbZ1QZ4ReZ5ziX90QejK9mh1TMs0ig33kGMw@mail.gmail.com>
On Mon, Dec 24, 2012 at 12:28:45PM +0700, Nguyen Thai Ngoc Duy wrote:
Show 8 quoted lines
> > You want to know "what commit was I at when I typed `git branch
> > mybranch`"?  The problem is git doesn't record this information and
> > doesn't have the slightest clue.
> 
> Maybe we should store this information. reflog is a perfect place for
> this, I think. If this information is reliably available, git rebase
> can be told to "rebase my whole branch" instead of my choosing the
> base commit for it.

Is that what you really want, though? We record the "upstream" branch already, and you can calculate the merge base with that branch to see which commits are unique to your branch. In simple cases, that is the same as "where did I start the branch". In more complex cases, it may not be (e.g., if you merged some of the early commits in the branch already). But in that latter case, would you really want to rebase those commits that had been merged?

The reason that git does not bother storing "where did I start this branch" is that it is usually not useful. The right question is usually "what is the merge base". There are exceptions, of course (e.g., if you are asking something like "what work did I do while checked out on the 'foo' branch"). But for merging and rebasing, I think the computed merge-base is much more likely to do what people want.

-Peff
Previous: Nguyen Thai Ngoc DuyNext: Nguyen Thai Ngoc Duy
Message 10 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.