Git - change master, push to complex branches?

So, I have a complex local branch: my main working local branch and two other branches. There was a new change in workshops that I want in my branches. What's the best way to propagate it to all of my branches? Is a reboot possible?

A---E---M  master 
     \ 
      F---G---H  local_branch_main
          |\ 
          | I---J  local_subbranch_1
           \K---L  local_subbranch_2

      

Ideally, I would like to just move all branches to the link of the new command (no conflicts):

A---E---M  master 
         \ 
          F---G---H  local_branch_main
              |\ 
              | I---J  local_subbranch_1
               \K---L  local_subbranch_2

      

+3


source to share


1 answer


You can do it this way

First do

git checkout local_branch_main
git rebase master

      

If you are lucky and you have no conflicts, your repository will now look like this:

A---E---M  master 
    \    \ 
     \    F'---G---H  local_branch_main
      F
      |\ 
      | I---J  local_subbranch_1
       \K---L  local_subbranch_2

      

Now here comes the interesting part. As you can see that commit F

and F'

contains the same changes (if there were no conflicts) but F'

has another commit of the parent and a different commit code. I make it visible by naming it F'

.

So now you can switch to the branch local_subbranch_1

and rebase it toF'



git checkout local_subbranch_1
git rebase F'

      

of course you should replace F'

with commit idF'

Your repository now looks like this

   A---E---M  master 
       \    \ 
        \    F'---G---H  local_branch_main
        F     \ 
         \     I---J  local_subbranch_1
          \
           K---L  local_subbranch_2

      

Finally, you can check local_subbranch_2

and reinstall it on F'

, and your repository will look like

   A---E---M  master 
            \ 
             F'---G---H  local_branch_main
             |\ 
             | I---J  local_subbranch_1
             \
               K---L  local_subbranch_2

      

I have created a demo repository that you can download here . You can reproduce the steps above.

0


source







All Articles