Git flow workflow - hotfix conflicts with branch permissions

时间:2017-06-20 12:32:37

标签: git branching-and-merging pull-request git-flow

I have a question that I feel like would be a common issue for many people. However, I'm unable to find any answer to my question.

I have a bitbucket repository that is using the git flow workflow (not using git-flow). However, I'm currently experiencing some workflow issues when using branch permissions. I have the following branch naming convention:

  • master
  • develop
  • hotfix/...
  • release/...
  • feature/...

I have configured my repository with write access, on branches master and develop, only through pull requests. For all other branches full permission is given, i.e. anyone can push code to them.

The problem I have can be explained by the following sequence of actions.

  1. A release was made a while ago. It got merged into origin/master and origin/develop.
  2. Development continues; feature branches is created and merged into origin/develop through pull requests.
  3. A critical bug is identified in the live code (origin/master).
  4. A hotfix branch is created from master, let's call it hotfix/some-hotfix.
  5. The bug is fixed and hotfix/some-hotfix branch is pushed to the repository. We now also have a remote branch origin/hotfix/some-hotfix. At this stage we have:

    • origin/develop is a head of origin/master by a number of commits (depends on how development has progressed).
    • origin/hotfix/some-hotfix is a head of master (by the commits made to fix the bug).
  6. A pull request is created to merge origin/hotfix/some-hotfix into origin/master. This will work fine, since origin/hotfix/some-hotfix is created from origin/master.

Note: The pull request is not necessarily resolved, i.e. origin/hotfix/some-hotfix is not merged into origin/master.

  1. A pull request is created to merge origin/hotfix/some-hotfix into origin/develop. This will, in many cases, results in conflicts; changes have been made to both branches.

I can't merge origin/develop into origin/hotfix/some-hotfix, since this branch is intended to me merged into origin/master. Any changes pushed to the hotfix branch, before a finalised pull request to master, will also end up in master. Changes made to develop might break master.

One solution is that, I can be very careful and make sure that any pull requests to master is completed before starting to process the pull requests to develop. In my opinion, this is not ideal. This is both risky (what if I forget) and hinders further development (no one can start to go through the pull request from hotfix to develop before master is done):

I feel like this would be a common problem with this workflow.

Questsion

Based on the above

  1. Am I interpreting the git flow workflow in the wrong way?
  2. How do you guys do it?
  3. How can i solve the problem, or avoid it altogether?

Thanks in advance

1 个答案:

答案 0 :(得分:0)

不,你没有以错误的方式解释工作流程。

我认为我们可以让这个hotfix/some-hotfix分支在master中合并。之后,我们可以将主分支合并到origin/develop以获取master分支的最新代码,或者我们可以使用origin/develop重新定义master分支。我认为合并更好。合并/重新定位develop

后,您必须解决master分支中的冲突