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

Re: Need some help with git rebase

From
Wincent Colaiuta <win@wincent.com>
Date
Dec 31, 2009, 11:06 UTC
Message-ID
<89AAB33C-89D4-46E9-A950-1CBFB4D2CBB3@wincent.com>
In-Reply-To
<7fce93be0912301502r77152c52sbccf762fb6c44610@mail.gmail.com>
El 31/12/2009, a las 00:02, Sylvain Rabot escribió:
Show 11 quoted lines
> In fact I want to backport the commits of the feature branch into  
> 12.72.1.
>
> I used git rebase because the drawings of the man page looked like  
> that I
> wanted to do and it does except for the part it resets the head of my
> feature branch.
>
> But as you said the good behavior would be to cherry pick each  
> commit of the
> feature branch and apply them into 12.72.1, right ?

Well rebasing is just a convenient way of cherry-picking a bunch of commits, so it's probably the right tool for the job.

But as you've seen, it has the effect of "moving" or "transplanting" the feature branch (replacing the old feature HEAD). If you really want the original feature branch HEAD to continue existing after the rebase you'll need to take some specific action to preserve it beforehand (creating a temporary branch before doing the rebase like Peter Baumann suggested) or restore it afterwards (using "git branch" like I suggested).

But before you actually do that, I'd make sure that you actually have a valid reason for keeping that branch around. Maybe wanting to "backport" those commits onto various different branches might be a valid reason. But it's worth thinking through because Git gives you various tools for supporting different workflows (merging, rebasing, cherry-picking) and they each have their use cases.

Cheers, Wincent

Previous: Tay Ray Chuan
Message 7 of 7 in “Need some help with git rebase”
  1. Sylvain RABOTDec 28, 2009
  2. Sylvain RabotDec 30, 2009
  3. Wincent ColaiutaDec 30, 2009
  4. Sylvain RabotDec 31, 2009
  5. Peter BaumannDec 31, 2009
  6. Tay Ray ChuanDec 31, 2009
  7. Wincent ColaiutaDec 31, 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.