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

Re: Rebase a whole tree from one commit to another?

From
Andreas Ericsson <ae@op5.se>
Date
May 16, 2009, 07:35 UTC
Message-ID
<4A0E6CC5.5090503@op5.se>
In-Reply-To
<4A0DC4CD.1030401@dirk.my1.cc>
Dirk Süsserott wrote:
Show 37 quoted lines
> Hi alltogether.
> 
> Let's say I have the following history:
> 
>     | | | | branch-c
>     | | | |
>     | | |/  branch-b
>     | | |
>     | |/    branch-a
>     | |
>     |/
>     | master
> 
> Now I checkout master, do some changes, and commit them to the master 
> branch. Let's call that new-master:
> 
>    | new-master
>    | | | | | branch-c
>    | | | | |
>    | | | |/  branch-b
>    | | | |
>    | | |/    branch-a
>    | | |
>    | |/
>     \| master
> 
> I want to rebase my branches a, b, c to the new master. The clumsy way 
> would be:
> 
>     git rebase new-master branch-a
>     git rebase branch-a   branch-b
>     git rebase branch-b   branch-c
> 
> The question is: Is there a way to rebase the whole tree (master -> 
> branch-a -> branch-b -> branch-c) from master to new-master with a 
> single command?
> 

No. You could merge all the branches that forked from master, rebase the merged branch to new-master and then undo the merge-commit though, but that would still mean three commands (and most likely some conflict resolution). Assuming you have (a lot) more than three branches, this might be a way forward for you.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Register now for Nordic Meet on Nagios, June 3-4 in Stockholm
 http://nordicmeetonnagios.op5.org/

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
Previous: Dirk SüsserottNext: Clemens Buchacher
Message 2 of 3 in “Rebase a whole tree from one commit to another?”
  1. Dirk SüsserottMay 15, 2009
  2. Andreas EricssonMay 16, 2009
  3. Clemens BuchacherMay 16, 2009

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.