Applying the changes from branch b to a, without merging or adding commits

前端 未结 5 858
逝去的感伤
逝去的感伤 2020-12-22 18:37

My scenario is that I have one branch in which I\'ve made big improvements to the build process (branch A) and in another I\'m working on a unrelated feature (branch B). So

5条回答
  •  长情又很酷
    2020-12-22 19:07

    I'm not sure I understand your requirements.

    You can run a merge, then call git reset HEAD~1.


    The following sequence should replay every commit between master and branchA on top of branchB. Commits which were already applied on branchB will be skipped.

    # start from branchA
    git checkout branchA
    # create a temporary branch wip
    git checkout -b wip
    # use rebase to replay each commit between master and wip on branchB
    git rebase --onto branchB master wip
    
    # if you want to remove all the commit history and only keep the resulting diffs,
    # use git reset
    git reset branchB
    
    # change the active branch
    git checkout branchB
    # remove temp branch
    git branch -d wip
    

提交回复
热议问题