Git: Merge a Commit into a different Branch

前端 未结 2 1997
小鲜肉
小鲜肉 2020-12-02 01:36

So I have 3 branches;

  • develop - my continued development branch
  • version_1 - a release branch
  • version_2
相关标签:
2条回答
  • 2020-12-02 02:02

    Merging only one or a few commits mean using git cherry-pick

    First cancel the merge you just did: see "Undo a Git merge?".
    Then:

    git checkout version_1
    git cherry-pick <commit checksum>
    

    That can apply to multiple commits or a range of commits: see "How to cherry pick a range of commits and merge into another branch".

    0 讨论(0)
  • 2020-12-02 02:11

    You need to cherry-pick those commits.

    Switch to the branch where you want to add the commits:

    git checkout develop
    

    Then, cherry-pick the commit. First do a git reflog and get the SHA-1 of the commit of the hotfix.

    Then, while you are on the branch develop, cherry-pick it

    git cherry-pick <commit SHA obtained above>
    

    Perform similar actions on the other branch version_1.

    0 讨论(0)
提交回复
热议问题