Florian
Florian

Reputation: 5994

Rebase From master To Other Branch

I've found some mistakes in my commit history. I used these steps to correct them and resolved all conflicts. Now my master branch is ok. But I've got another branch. Lets call it "Branch 1": enter image description here

I would like to apply the changes made to the master branch also to Branch 1. I've made the changes at the orange commit. I've resolved all conflicts until the last commit of the master branch. How can I apply these changes to Branch 1 also?

Upvotes: 3

Views: 150

Answers (2)

knittl
knittl

Reputation: 265131

Making lots of assumptions here. Let's draw your current history anew, to make discussing it easier:

     .-D'-E'      -- master' (after rebase)
A-B-C-D-E         -- master  (before rebase)
         `F-G-H   -- branch1 (before rebase)

If I understood correctly, your final history should:

           .-F'-G'-H' -- branch1 (after rebase)
     .-D'-E'          -- master' (after rebase)
A-B-C-D-E             -- master  (before rebase)
         `F-G-H       -- branch1 (before rebase)

Or, hiding the old branches (before rebase):

A-B-C-D'-E'           -- master  (after rebase)
          `F'-G'-'H   -- branch1 (after rebase)

You should be able to achieve this by specifying which commit range to rebase and what your new upstream should be:

git rebase --onto "E'" E branch1

This will copy all commits E..branch1 and re-apply them on top of E'.

Upvotes: 1

pramesh
pramesh

Reputation: 1954

You can cherry pick the required commit. That would be the best to get the changes from other branch.

Upvotes: 0

Related Questions