Managing hotfixes when develop branch is very different from master?

前端 未结 4 886
春和景丽
春和景丽 2020-12-07 10:19

I\'m using the \"Git Flow\" branching model, with a master branch and a develop branch. I\'m working on a major new release, so my develop branch is wildly different from my

4条回答
  •  再見小時候
    2020-12-07 10:47

    The simplest way to get some commits from one branch to another is cherry-picking.

    Assuming that your fix in master has the commit hash HASH and you want to take that hotfix into your devel branch, do a git checkout devel followed by a git cherry-pick HASH. That's it.

    If you want to take all changes from master into devel, you can achieve that with

    git checkout devel
    git rebase master
    

    If you have the opposite scenario (you make a hotfix during development in a devel branch and want to take that fix into master before devel gets fully merged into master), the workflow is quite similar. Assuming that the hotfix has the hash HOTFIX_HASH, do this:

    git checkout master
    git cherry-pick HOTFIX_HASH
    

    Now, the commit is present in master and devel. To get around this, type

    git checkout devel
    git rebase master
    

    and the commit will disappear from devel since it's already present in master.

提交回复
热议问题