Thread (13 messages) flat view 13 messages, 7 authors, 2016-06-15

Re: Find the starting point of a local branch

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:55:35

On Mon, Dec 24, 2012 at 1:19 PM, Jeff King [off-list ref] wrote:
On Mon, Dec 24, 2012 at 12:28:45PM +0700, Nguyen Thai Ngoc Duy wrote:
quoted
quoted
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.
Rebasing is exactly why I want this. Merge base works most of the time
until you rewrite upstream (which I do sometimes). There are also
cases when I create a branch without upstream, or when upstream is
renamed. Still, making "rebase -i --topic" == "rebase -i $(git
merge-base HEAD @{upstream})" would be cool.
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help