Search code examples
gitbitbucketbranching-and-mergingsourcetree

How to push changes from branch A to branch B without removing new changes from B branch git (no merge)


I am working with git since a long time. The challenge am facing now is bit confusing. My problem is managing repository with different releases of the application.

I am working on an application in which i have to release several modules of the application and i will have to continue development in proceeding modules without waiting for the testing issues of previous modules. So I have created different branches for each module and working on them leaving the old branch to a position where the changes for that module is completed. Its ok but the problem is when the tester will give issues on old module i will have to fix those particular issues on the old branch and those fixes should also reflect on new working branch and future branches of source codes. And i will have to give a build with fixes of old branch only till the old branch task target without the new changes from new branch.

I am using source tree mac application to manage my repository. Is there any way to achieve this task. What i am doing right now is simultaneously modifying source codes of 2 repositories for single issue fix and i am afraid if i have to do this for 3 repositories which is horrible because i am about to finish the 2nd module also. I hope there must be a way.


Solution

  • Use cherry-pick.

    branch_a : A - B - C <- tip
    branch_b : D - E - F <- tip
    

    To cherry-pick commit E from branch_b to branch_a, do:

    git checkout branch_a
    git cherry-pick E
    

    And you will end up with:

    branch_a : A - B - C - E' <- HEAD
    branch_b : D - E - F <-tip
    

    Where E' is identical to E but on top of C.