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

Re: git rebase syntax question

From
Jeff King <peff@peff.net>
Date
Aug 11, 2006, 22:07 UTC
Message-ID
<20060811220717.GC4788@sigio.intra.peff.net>
In-Reply-To
<44DCC880.1080108@austin.rr.com>
On Fri, Aug 11, 2006 at 01:12:16PM -0500, Steve French wrote:
Show 6 quoted lines
> The git repository is cloned from 
> /pub/scm/linux/kernel/git/torvalds/linux-2.6.git and has one branch and 
> history like
>         ...->A->MyCommits->B->MoreOfMyCommits->C->EmptyMergeMessages
> and I want to make my master look like
>         ...->A->B->C->MyCommits->MoreOfMyCommits
Since A, B, and C are from upstream, they should still be linked
directly together. So your history is probably more like this:
    MyCommits--Merge--MoreOfMyCommits--EmptyMergeMessage
   /          /                       /
  A----------B-----------------------C
> I tried doing the obvious
>    "git rebase master"
> but that appears to be a no op
You are already merged with master, so rebase doesn't think there is
anything to do. You will have to rebase each of your merged segments
onto a new rebase branch:
  # Go back to just before the first merge...
  $ git-branch commits1 Merge^
  # And add all of C..commits1 on top of C
  $ git-rebase C commits1
  # Now we go back for the second merge...
  $ git-branch commits2 EmptyMergeMessage^
  # And add all of that on top of our previous work
  $ git-rebase commits1 commits2
  # At this point commits2 has A->B->C->MyCommits->MoreOfMyCommits.
  # Now we can clean things up, making master the new desired branch.
  $ git-checkout master
  $ git-reset --hard commits2
  $ git-branch -d commits1 commits2
  $ git-prune

I'm not sure if there's a simpler way to do it. Obviously if you do the rebase as you go along (instead of merging) it's much easier.

-Peff
Previous: Steve French
Message 2 of 2 in “git rebase syntax question”
  1. Steve FrenchAug 11, 2006
  2. Jeff KingAug 11, 2006

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.