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

Re: Find the starting point of a local branch

From
Martin von Zweigbergk <martinvonz@gmail.com>
Date
Dec 28, 2012, 06:38 UTC
Message-ID
<CANiSa6iuiuDxjTdn9-DD3y2-OA=jffxGM0ibVrZB1ixLy0i+Gg@mail.gmail.com>
In-Reply-To
<20121228051514.GA4028@zuhnb712.ap.bm.net>
On Thu, Dec 27, 2012 at 9:15 PM, Woody Wu <narkewoody@gmail.com> wrote:
Show 13 quoted lines
> 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 <narkewoody@gmail.com> 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.<name>.*" 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 . <upstream branch>".

> 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 <branch>) $(git rev-list -g <upstream branch>)
Hope that helps
Previous: Woody Wu
Message 17 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.