All of lore.kernel.org
 help / color / mirror / Atom feed
From: Seth Robertson <in-gitvger@baka.org>
To: Woody Wu <narkewoody@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: Find the starting point of a local branch
Date: Sun, 23 Dec 2012 23:09:58 -0500	[thread overview]
Message-ID: <201212240409.qBO49wkV020768@no.baka.org> (raw)
In-Reply-To: <20121224035825.GA17203@zuhnb712>


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

  reply	other threads:[~2012-12-24  4:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-24  3:58 Find the starting point of a local branch Woody Wu
2012-12-24  4:09 ` Seth Robertson [this message]
2012-12-24  5:28   ` Nguyen Thai Ngoc Duy
2012-12-24  5:34     ` Tomas Carnecky
2012-12-24  5:45       ` Nguyen Thai Ngoc Duy
2012-12-24  6:27         ` Junio C Hamano
2012-12-24 11:21           ` Nguyen Thai Ngoc Duy
2012-12-24 19:10             ` Junio C Hamano
2012-12-25  1:09               ` Nguyen Thai Ngoc Duy
2012-12-24  6:19     ` Jeff King
2012-12-24 11:16       ` Nguyen Thai Ngoc Duy
2012-12-24 15:34         ` Jeff King
2012-12-24  7:31   ` Woody Wu
2012-12-24  9:12     ` Kevin
2012-12-24 17:24     ` Martin von Zweigbergk
2012-12-28  5:15       ` Woody Wu
2012-12-28  6:38         ` Martin von Zweigbergk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201212240409.qBO49wkV020768@no.baka.org \
    --to=in-gitvger@baka.org \
    --cc=git@vger.kernel.org \
    --cc=narkewoody@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.