문제

I have the following tree:

branch1               G---H---I
                     /   
master       A---B---C---D---E---F
                          \
branch2                    M---N---O

I need to make some modifications in B. Is there any easy way to spread the modifications to all the branches (master, branch1 and branch2) ?

도움이 되었습니까?

해결책

The safest way to do this is:

  1. Create a new branch from B

    git checkout -b BPRIME SHA_OF_B

  2. Make some changes, and commit them. you're graph will look like:

    BPRIME              B'
                       /  
    branch1           /   G---H---I
                     /   /   
    master       A---B---C---D---E---F
                              \
    branch2                    M---N---O
    
  3. Then cherry pick the commits from BPRIME to each of the branches.

    $ git checkout branch1 && git cherry-pick B'
    $ git checkout master && git cherry-pick B'
    $ git checkout branch2 && git cherry-pick B'
    

This is the safest option because you are not changing the history.

다른 팁

Make the new commit in master branch and then rebase the other branches with the master.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top