Alternatives to cherry-picking

前端 未结 3 795
情歌与酒
情歌与酒 2021-02-06 02:46

We have a master and a production branch. The master branch contains current developments while the production branch contains the stuff that is running on the s

相关标签:
3条回答
  • 2021-02-06 03:07

    You can create a new branch (let's call it bugfix-a) at the merge base of master and production

    git checkout -b bugfix-a $(git merge-base master production)
    

    Apply your bugfix in that branch

    >>/path/to/file echo 'this fixes the bug'
    git add /path/to/file
    git commit -m 'important bugfix'
    

    Then, merge this new branch to both master and production:

    git checkout master
    git merge bugfix-a
    git checkout production
    git merge bugfix-a
    

    That way you should be able to merge master and production at a later date and Git will be clever enough to figure out which commits to pick.

    (Monotone – yes, it's not Git – calls this workflow daggy fixes)

    0 讨论(0)
  • 2021-02-06 03:17

    Create a separate branch for each hotfix, and merge it into both your development branch and your production branch.

    The gitflow model works really well in general, and I'd recommend checking this out: http://nvie.com/posts/a-successful-git-branching-model/

    Your master branch is analogous to their develop branch, and your production branch is analogous to their master

    enter image description here

    0 讨论(0)
  • 2021-02-06 03:18

    You could use Gitflow. I think the 'hotfix' handles your scenario.

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