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

Re: Can't get git rebase --onto to work

From
Howard Miller <howard@e-learndesign.co.uk>
Date
Jun 2, 2011, 10:43 UTC
Message-ID
<BANLkTin92KXYO3YF1UytcesWUV-Nh_LaGg@mail.gmail.com>
In-Reply-To
<20110602103833.GA4709@Imperial-SSD-Overlord>
On 2 June 2011 11:38, Tim Guirgies <lt.infiltrator@gmail.com> wrote:
Show 70 quoted lines
> On Thu, Jun 02, 2011 at 11:17:41AM +0100, Howard Miller wrote:
>> Trying to explain this as concisely as possible.
>>
>> I started with the following branches (names changed to protect the guilty)...
>>
>> * clientA
>> * clientB
>>
>> both have a common ancestry....
>>
>> I then checked out clientB created a new branch clientB_patch and did
>> a load of work and commits.
>>
>> However, I actually wanted all those commits to apply to clientA
>> branch instead so....
>>
>> git checkout clientA
>> git checkout -b clientA_patch     (to ensure I didn't wreck original branch)
>> git rebase --onto clientA_patch clientB clientB_patch
>>
>> It says "rewinding" head and then applies the commits I would have expected.
>>
>> However, I have now been switched to the 'clientB_patch' branch and it
>> says that it differs from its tracked remote branch by hundreds of
>> commits.
>>
>> clientA_patch is unchanged. It seems to have mangled clientB_patch and
>> done nothing to clientA_patch. Where did I go wrong?
>
> "--onto clientA_patch"
>
> Please read that out loud.  It's meaning in git is the same as in
> English.  What you did was rebase clientB_patch _onto_ clientA_patch.
> For more information, see "git help rebase".
>
> What you should have done instead:
>
> git checkout -b clientA_patch clientB_patch
> git rebase -i clientA
>
> What that does is create and then checkout a branch called clientA_patch
> at the same commit as clientB_patch, then rebase your currently checked
> out branch (clientA_patch) on top of clientA; the "-i" option allows you
> double check what's being rebased, as otherwise it would take a whole
> lot clientB history with it.  Simply delete the lines with the commits
> you don't want.
>
>
> To fix what you currently have, though, you must do the following.  Take
> heed, however, as I making assumptions that the situation is unchanged
> from what you described above.
>
> git checkout clientB_patch
> git reset --hard origin/clientB_patch
>
> I'm assuming your remote is called origin, and also that whatever you
> pushed last is the latest.  If not, you'll have to look at "git reflog"
> to see which commit to reset the branch to.
>
> Now do:
>
> git checkout clientA_patch
> git reset --hard clientB_patch
> git rebase -i clientA
>
> That should give you what you want.
>
> Good luck.
>
>
Hi Tim,

Thanks for the lengthy post :) As I said in my previous post, I think/hope I have resolved it. I did read the manpage first (I'm not so brave not to before posting here!!) and it did what it said it would. I just misinterpreted it. A final merge was required. I actually picked that up from the "Pro Git" book page which mentions that extra step.

Previous: Tim GuirgiesNext: Tim Guirgies
Message 5 of 10 in “Can't get git rebase --onto to work”
  1. Howard MillerJun 2, 2011
  2. Carlos Martín NietoJun 2, 2011
  3. Howard MillerJun 2, 2011
  4. Tim GuirgiesJun 2, 2011
  5. Howard MillerJun 2, 2011
  6. Tim GuirgiesJun 2, 2011
  7. Howard MillerJun 2, 2011
  8. DavidJun 2, 2011
  9. Tim GuirgiesJun 2, 2011
  10. Howard MillerJun 2, 2011

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.