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

Re: Find the starting point of a local branch

From
WWWoody Wu <narkewoody@gmail.com>
Date
Dec 24, 2012, 07:31 UTC
Message-ID
<20121224073103.GA10793@zuhnb712>
In-Reply-To
<201212240409.qBO49wkV020768@no.baka.org>
On Sun, Dec 23, 2012 at 11:09:58PM -0500, Seth Robertson wrote:
Show 16 quoted lines
> 
> 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.
Show 9 quoted lines
>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.

Show 7 quoted lines
> 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.
Previous: Jeff KingNext: Kevin
Message 13 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.