Git merging hotfix to multiple branches

后端 未结 4 1054
-上瘾入骨i
-上瘾入骨i 2021-02-01 16:48

I\'ve been trying to wrap my head around git branching models. I\'ve been looking at http://nvie.com/posts/a-successful-git-branching-model/ for some ideas and coming from Subv

4条回答
  •  我在风中等你
    2021-02-01 17:47

    If you wanted to get super-technical about it, you could create the hotfix from a common ancestor:

    git merge-base v3 master
    git checkout -b hotfix 
    # make your fix
    git checkout v3 && git merge --no-ff hotfix
    git checkout master && git merge --no-ff hotfix
    
            v3--------v3 (hotfixed)
           /         /
    ancestor----hotfix
           \         \
            master----master (hotfixed)
    

    The --no-ff flag is there to highlight that Git will create a merge commit, keeping the hotfix branch label at the hotfix tip, instead of pulling the label to v3 or master. (You can omit the flag and get the same behavior, since the hotfix branch has one commit that isn't in master or v3. More info in the docs.)

    Personally, I think that's overkill. I'd go with gahooa: make the hotfix on the branch that makes sense, then merge or cherry-pick depending on how you want the branches to relate to each other.

提交回复
热议问题