Re: Find the starting point of a local branch

2012-12-27 Thread Martin von Zweigbergk
On Thu, Dec 27, 2012 at 9:15 PM, Woody Wu  wrote:
> On Mon, Dec 24, 2012 at 09:24:39AM -0800, Martin von Zweigbergk wrote:
>> On Sun, Dec 23, 2012 at 11:31 PM, Woody Wu  wrote:
>> >
>> > This is not working to me since I have more than one local branch that
>> > diverged from the master, and in fact, the branch I have in question was
>> > diverged from another local branch.
>>
>> As Jeff mentions in a later message, "git pull --rebase" would
>> probably do what you want. It works with local branches too.
>>
>
> I think what 'git pull --rebase' would do is to fetch from the origin
> and do a 'git rebase'.

Not if the configured upstream is a local branch (see the
"branch..*" configuration variables). In that case it will just
rebase the local branch onto the new position of its upstream. If the
upstream is not configured, I believe you can still do "git pull
--rebase . ".

> On one hand, I don't understand 'git rebase' so
> much from the manual, ont the other hand, I did not get the point why
> 'git rebase' has something to do with the thing I want to do (what I
> want is just query some kind of history information).

I may have misunderstood or assumed things incorrectly that you wanted
to rebase the commits on your branch. So why do you want to know?
(Please ignore me if this was answered elsewhere in the thread that I
might have missed.)

Anyway, to answer your question, you could use a method similar to
what "git pull --rebase" uses internally to figure out the branch
point:

git merge-base $(git rev-parse ) $(git rev-list -g )

Hope that helps
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-27 Thread Woody Wu
On Mon, Dec 24, 2012 at 09:24:39AM -0800, Martin von Zweigbergk wrote:
> On Sun, Dec 23, 2012 at 11:31 PM, Woody Wu  wrote:
> > On Sun, Dec 23, 2012 at 11:09:58PM -0500, Seth Robertson wrote:
> >>
> >> In message <20121224035825.GA17203@zuhnb712>, Woody Wu writes:
> >>
> >> How can I find out what's the staring reference point (a commit number
> >> or tag name) of a locally created branch? I can use gitk to find out it
> >> but this method is slow, I think there might be a command line to do it
> >> quickly.
> >>
> >> The answer is more complex than you probably suspected.
> >>
> >> Technically, `git log --oneline mybranch | tail -n 1` will tell you
> >> the starting point of any branch.  But...I'm sure that isn't what you
> >> want to know.
> >>
> >> You want to know "what commit was I at when I typed `git branch
> >> mybranch`"?
> >
> > Yes, this is exactly I want to know.
> >
> >>The problem is git doesn't record this information and
> >> doesn't have the slightest clue.
> >>
> >> But, you say, I can use `gitk` and see it.  See?  Right there.  That
> >> isn't (necessarily) the "starting point" of the branch, it is the
> >> place where your branch diverged from some other branch.  Git is
> >> actually quite able to tell you when the last time your branch
> >> diverged from some other branch.  `git merge-base mybranch master`
> >> will tell you this, and is probably the answer you were looking for.
> >
> > This is not working to me since I have more than one local branch that
> > diverged from the master, and in fact, the branch I have in question was
> > diverged from another local branch.
> 
> As Jeff mentions in a later message, "git pull --rebase" would
> probably do what you want. It works with local branches too.
> 

I think what 'git pull --rebase' would do is to fetch from the origin
and do a 'git rebase'.  On one hand, I don't understand 'git rebase' so
much from the manual, ont the other hand, I did not get the point why
'git rebase' has something to do with the thing I want to do (what I
want is just query some kind of history information).

I know, my knowledge about git is still so limit. I will keep study from
the man pages.


> I once tried to add the same cleverness that "git pull --rebase"
> directly in "git rebase" [1], but there were several issues with those
> patches, one of was regarding the performance ("git pull --rebase" can
> be equally slow, but since it often involves network, users probably
> rarely notice). I think it would be nice to at least add it as an
> option to "git rebase" some day. Until then, "git pull --rebase" works
> fine.
> 
>  [1] http://thread.gmane.org/gmane.comp.version-control.git/166710

-- 
woody
I can't go back to yesterday - because I was a different person then.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-24 Thread Nguyen Thai Ngoc Duy
On Tue, Dec 25, 2012 at 2:10 AM, Junio C Hamano  wrote:
>> I looked briefly at reflog before writing my previous mail and noticed
>> that when I create a new branch (usually using "git checkout -b branch
>> ref") it does not record the base commit.
>
> Hmph.  Perhaps you are referring to something different than what I
> think "the base commit" with that word.
>
> $ git reflog mz/pick-unborn | tail -n 1
> b3cf6f3 mz/pick-unborn@{3}: branch: Created from ko/master

No you're right. My reflogs must be pruned. Creating a new branch does
produce that entry.

>> We could at least invalidate the recorded base in reflog and let user
>> define a new one (I hope).
>
> Please do not even think about going back and rewrite to lose
> information.  If the records have full information, you should be
> able to reconstruct what you want from it without rewriting.
>
> Even more importantly, wish to "invalidate" indicates that you know
> at a newer point that you have more authoritative information than
> the older reflog entries, so you should be able to do the moral
> equivalent by writing the event as establishing a new base at that
> point (e.g. "checkout -B"), and stopping at that point in the reflog
> when reading, without losing the older reflog entries.

Exactly. And when we prune the reflog, we could add the base back so
the base is always in reflog.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-24 Thread Junio C Hamano
Nguyen Thai Ngoc Duy  writes:

> On Mon, Dec 24, 2012 at 1:27 PM, Junio C Hamano  wrote:
>> Nguyen Thai Ngoc Duy  writes:
>>
>>> On Mon, Dec 24, 2012 at 12:34 PM, Tomas Carnecky
>>>  wrote:
> 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.

 What's the starting point of the branch if I type: git branch foo 
 ?
>>>
>>> You start working off  so I think the starting point would
>>> be .
>>
>> Yeah, that sounds sensible.  Don't we already have it in the reflog,
>> though?
>
> I looked briefly at reflog before writing my previous mail and noticed
> that when I create a new branch (usually using "git checkout -b branch
> ref") it does not record the base commit.

Hmph.  Perhaps you are referring to something different than what I
think "the base commit" with that word.

$ git reflog mz/pick-unborn | tail -n 1
b3cf6f3 mz/pick-unborn@{3}: branch: Created from ko/master

>> What is trickier is when you later transplant it to some other base
>> (perhaps prepare a topic on 'master', realize it should better apply
>> to 'maint' and move it there).  If the user did the transplanting by
>> hand, reflog would probably not have enough information, e.g. after
>>
>> $ git checkout maint^0
>> $ git log --oneline master..topic
>> $ git cherry-pick $one_of_the_commit_names_you_see_in_the_above
>> $ git cherry-pick $another_commit_name_you_see_in_the_above
>>   ...
>> $ git branch -f topic
>>
>> no reflog other than HEAD@{} will tell you that you were at maint^0,
>> so the reflog of topic wouldn't know it "forked" from there, either.
>
> We could at least invalidate the recorded base in reflog and let user
> define a new one (I hope).

Please do not even think about going back and rewrite to lose
information.  If the records have full information, you should be
able to reconstruct what you want from it without rewriting.

Even more importantly, wish to "invalidate" indicates that you know
at a newer point that you have more authoritative information than
the older reflog entries, so you should be able to do the moral
equivalent by writing the event as establishing a new base at that
point (e.g. "checkout -B"), and stopping at that point in the reflog
when reading, without losing the older reflog entries.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-24 Thread Martin von Zweigbergk
On Sun, Dec 23, 2012 at 11:31 PM, Woody Wu  wrote:
> On Sun, Dec 23, 2012 at 11:09:58PM -0500, Seth Robertson wrote:
>>
>> In message <20121224035825.GA17203@zuhnb712>, Woody Wu writes:
>>
>> How can I find out what's the staring reference point (a commit number
>> or tag name) of a locally created branch? I can use gitk to find out it
>> but this method is slow, I think there might be a command line to do it
>> quickly.
>>
>> The answer is more complex than you probably suspected.
>>
>> Technically, `git log --oneline mybranch | tail -n 1` will tell you
>> the starting point of any branch.  But...I'm sure that isn't what you
>> want to know.
>>
>> You want to know "what commit was I at when I typed `git branch
>> mybranch`"?
>
> Yes, this is exactly I want to know.
>
>>The problem is git doesn't record this information and
>> doesn't have the slightest clue.
>>
>> But, you say, I can use `gitk` and see it.  See?  Right there.  That
>> isn't (necessarily) the "starting point" of the branch, it is the
>> place where your branch diverged from some other branch.  Git is
>> actually quite able to tell you when the last time your branch
>> diverged from some other branch.  `git merge-base mybranch master`
>> will tell you this, and is probably the answer you were looking for.
>
> This is not working to me since I have more than one local branch that
> diverged from the master, and in fact, the branch I have in question was
> diverged from another local branch.

As Jeff mentions in a later message, "git pull --rebase" would
probably do what you want. It works with local branches too.

I once tried to add the same cleverness that "git pull --rebase"
directly in "git rebase" [1], but there were several issues with those
patches, one of was regarding the performance ("git pull --rebase" can
be equally slow, but since it often involves network, users probably
rarely notice). I think it would be nice to at least add it as an
option to "git rebase" some day. Until then, "git pull --rebase" works
fine.

 [1] http://thread.gmane.org/gmane.comp.version-control.git/166710
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-24 Thread Jeff King
On Mon, Dec 24, 2012 at 06:16:05PM +0700, Nguyen Thai Ngoc Duy wrote:

> > 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).

True, although wouldn't you generally want to rebase it on top of the
rewritten upstream in that case (which is what "pull --rebase" will do,
by scanning the reflog for the last version of the upstream that you
actually built on).

> 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.

Yeah. I usually just do "rebase -i @{upstream}" which picks the same
commits, but moves to the updated version of upstream (IOW, I both
rewrite and move forward at the same time). But there is value in
rewriting without moving forward in many workflows. That seems like a
sensible feature to me.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-24 Thread Nguyen Thai Ngoc Duy
On Mon, Dec 24, 2012 at 1:27 PM, Junio C Hamano  wrote:
> Nguyen Thai Ngoc Duy  writes:
>
>> On Mon, Dec 24, 2012 at 12:34 PM, Tomas Carnecky
>>  wrote:
 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.
>>>
>>> What's the starting point of the branch if I type: git branch foo 
>>> ?
>>
>> You start working off  so I think the starting point would
>> be .
>
> Yeah, that sounds sensible.  Don't we already have it in the reflog,
> though?

I looked briefly at reflog before writing my previous mail and noticed
that when I create a new branch (usually using "git checkout -b branch
ref") it does not record the base commit.

> What is trickier is when you later transplant it to some other base
> (perhaps prepare a topic on 'master', realize it should better apply
> to 'maint' and move it there).  If the user did the transplanting by
> hand, reflog would probably not have enough information, e.g. after
>
> $ git checkout maint^0
> $ git log --oneline master..topic
> $ git cherry-pick $one_of_the_commit_names_you_see_in_the_above
> $ git cherry-pick $another_commit_name_you_see_in_the_above
>   ...
> $ git branch -f topic
>
> no reflog other than HEAD@{} will tell you that you were at maint^0,
> so the reflog of topic wouldn't know it "forked" from there, either.

We could at least invalidate the recorded base in reflog and let user
define a new one (I hope).
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-24 Thread Nguyen Thai Ngoc Duy
On Mon, Dec 24, 2012 at 1:19 PM, Jeff King  wrote:
> On Mon, Dec 24, 2012 at 12:28:45PM +0700, Nguyen Thai Ngoc Duy wrote:
>
>> > 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-24 Thread Kevin
On Mon, Dec 24, 2012 at 8:31 AM, Woody Wu  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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-23 Thread Woody Wu
On Sun, Dec 23, 2012 at 11:09:58PM -0500, Seth Robertson wrote:
> 
> In message <20121224035825.GA17203@zuhnb712>, Woody Wu writes:
> 
> How can I find out what's the staring reference point (a commit number
> or tag name) of a locally created branch? I can use gitk to find out it
> but this method is slow, I think there might be a command line to do it
> quickly.
> 
> The answer is more complex than you probably suspected.
> 
> Technically, `git log --oneline mybranch | tail -n 1` will tell you
> the starting point of any branch.  But...I'm sure that isn't what you
> want to know.
> 
> You want to know "what commit was I at when I typed `git branch
> mybranch`"?  

Yes, this is exactly I want to know.

>The problem is git doesn't record this information and
> doesn't have the slightest clue.
> 
> But, you say, I can use `gitk` and see it.  See?  Right there.  That
> isn't (necessarily) the "starting point" of the branch, it is the
> place where your branch diverged from some other branch.  Git is
> actually quite able to tell you when the last time your branch
> diverged from some other branch.  `git merge-base mybranch master`
> will tell you this, and is probably the answer you were looking for.

This is not working to me since I have more than one local branch that
diverged from the master, and in fact, the branch I have in question was
diverged from another local branch.  With the method of 'git
merge-base', I have to remember a branch tree in my brain.

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.


> Note that this is the *last* divergence.  If your branch diverged and
> merged previously that will not be reported.  Even worse, if you did a
> fast-forward merge (I recommend against them in general) then it is
> impossible to discover about what the independent pre-merge history
> was really like.
> 
>   -Seth Robertson

-- 
woody
I can't go back to yesterday - because I was a different person then.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-23 Thread Junio C Hamano
Nguyen Thai Ngoc Duy  writes:

> On Mon, Dec 24, 2012 at 12:34 PM, Tomas Carnecky
>  wrote:
>>> 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.
>>
>> What's the starting point of the branch if I type: git branch foo 
>> ?
>
> You start working off  so I think the starting point would
> be .

Yeah, that sounds sensible.  Don't we already have it in the reflog,
though?

What is trickier is when you later transplant it to some other base
(perhaps prepare a topic on 'master', realize it should better apply
to 'maint' and move it there).  If the user did the transplanting by
hand, reflog would probably not have enough information, e.g. after

$ git checkout maint^0
$ git log --oneline master..topic
$ git cherry-pick $one_of_the_commit_names_you_see_in_the_above
$ git cherry-pick $another_commit_name_you_see_in_the_above
  ...
$ git branch -f topic

no reflog other than HEAD@{} will tell you that you were at maint^0,
so the reflog of topic wouldn't know it "forked" from there, either.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-23 Thread Jeff King
On Mon, Dec 24, 2012 at 12:28:45PM +0700, Nguyen Thai Ngoc Duy wrote:

> > 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-23 Thread Nguyen Thai Ngoc Duy
On Mon, Dec 24, 2012 at 12:34 PM, Tomas Carnecky
 wrote:
>> 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.
>
> What's the starting point of the branch if I type: git branch foo 
> ?

You start working off  so I think the starting point would
be .
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-23 Thread Tomas Carnecky
On Mon, 24 Dec 2012 12:28:45 +0700, Nguyen Thai Ngoc Duy  
wrote:
> On Mon, Dec 24, 2012 at 11:09 AM, Seth Robertson  wrote:
> >
> > In message <20121224035825.GA17203@zuhnb712>, Woody Wu writes:
> >
> > How can I find out what's the staring reference point (a commit number
> > or tag name) of a locally created branch? I can use gitk to find out it
> > but this method is slow, I think there might be a command line to do it
> > quickly.
> >
> > The answer is more complex than you probably suspected.
> >
> > Technically, `git log --oneline mybranch | tail -n 1` will tell you
> > the starting point of any branch.  But...I'm sure that isn't what you
> > want to know.
> >
> > 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.

What's the starting point of the branch if I type: git branch foo ?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-23 Thread Nguyen Thai Ngoc Duy
On Mon, Dec 24, 2012 at 11:09 AM, Seth Robertson  wrote:
>
> In message <20121224035825.GA17203@zuhnb712>, Woody Wu writes:
>
> How can I find out what's the staring reference point (a commit number
> or tag name) of a locally created branch? I can use gitk to find out it
> but this method is slow, I think there might be a command line to do it
> quickly.
>
> The answer is more complex than you probably suspected.
>
> Technically, `git log --oneline mybranch | tail -n 1` will tell you
> the starting point of any branch.  But...I'm sure that isn't what you
> want to know.
>
> 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.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Find the starting point of a local branch

2012-12-23 Thread Seth Robertson

In message <20121224035825.GA17203@zuhnb712>, Woody Wu writes:

How can I find out what's the staring reference point (a commit number
or tag name) of a locally created branch? I can use gitk to find out it
but this method is slow, I think there might be a command line to do it
quickly.

The answer is more complex than you probably suspected.

Technically, `git log --oneline mybranch | tail -n 1` will tell you
the starting point of any branch.  But...I'm sure that isn't what you
want to know.

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.

But, you say, I can use `gitk` and see it.  See?  Right there.  That
isn't (necessarily) the "starting point" of the branch, it is the
place where your branch diverged from some other branch.  Git is
actually quite able to tell you when the last time your branch
diverged from some other branch.  `git merge-base mybranch master`
will tell you this, and is probably the answer you were looking for.
Note that this is the *last* divergence.  If your branch diverged and
merged previously that will not be reported.  Even worse, if you did a
fast-forward merge (I recommend against them in general) then it is
impossible to discover about what the independent pre-merge history
was really like.

-Seth Robertson
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html