Mark Rogers
Mark Rogers

Reputation: 97717

Is there a gitflow process for branching and bug fixes with a release branch?

In order to have make sure all code eventually goes through pull request code review, we've started creating branches for features and bug branches off of develop following the git-flow style.

The only problem is that once a bug is found in a release branch, we often have to make a branch off of the release branch in order to do a pull request back to the release branch. But there doesn't seem to be an obvious git-flow process for handling branches off of the release branch when bug fixing a release branch.

What is the git-flow process for fixing release branch bugs and code review?

Are you supposed to fix the bug in develop and create a new release branch? Is branching off of a release branch still valid git-flow? What's the best way to handle pull request code reviews on release branch bug fixes?

Upvotes: 8

Views: 4927

Answers (3)

smurphy
smurphy

Reputation: 133

I just came accross this same issue. I suggest creating a normal branch from the release branch. Make your fixes there and create a pull request for that branch to be merged to the release branch. This is using the normal branch and merge commands and not the Git Flow commands.

Step details below:

  1. checkout the release/2017.05.24 branch. Where 2017.05.24 is the name of the release branch.
  2. Execute the branch command and name it “release2017.05.24 - reason for fix”. This will make it obvious why the branch exists (for release fix).
  3. Make your changes, commit, push your changes up to the server (push your branch to origin).
  4. In your server create a pull request for your branch to merge to the release/2017.05.24 branch. NOTE: merging to release/2017.05.24 branch is NOT the default so be sure to change that before creating the pull request.
  5. On code review approval checkout “release/2017.05.24”
  6. Execute the merge command picking your commit in “release2017.05.24 -reason for fix” branch.
  7. Delete the local and remote branches for your “release2017.05.24 - reason for fix” branch

Hopefully that will work better. Lots of steps and brakes from the Git-flow command set but should allow the pull requests to happen.

Upvotes: 4

Joe Phillips
Joe Phillips

Reputation: 51150

Bug fix branches should be branched off master (or whatever branch represents your production code). If you're using git flow, this sometimes means you have to cherry pick commits into the bug fix branch if you've already made the code change in a branch off of develop.

Upvotes: 0

Mike Tung
Mike Tung

Reputation: 4821

The way I handle it would be to have a hotfix branch off the release branch. After fixing the bug I would merge in to master/release branch and also merge to Dev branch which would then trickle down to the other features.

The hotfix would then be deleted because it'll be recorded in master or dev.

Upvotes: 1

Related Questions