How to hotfix a feature that's already in develop (git-flow)

1.5k Views Asked by At

Scenario - using git-flow or similar:

While underway with a stream of work, we become aware that one of the features which has been developed (in a feature-branch and already merged to the develop branch) needs to be urgently hotfixed before the other work in develop will be ready.

What is best practice for achieving this?

In git-flow, hotfixes are typically done using a hotfix branch off master. To follow that model, I'm wondering whether cherry-picking from develop to the hotfix branch is best, or retaining the feature branches after they've been merged to develop and merging those branches to the hotfix branch (or master)? Or something else?

1

There are 1 best solutions below

0
On

First, I'd like to stress that "the good workflow" does not exists in general, "the good workflow" is the one you feel convenient to work with.

That said, I personnally consider two situations:

  • the hotfix is trivial (like replacing "Version A" by "Version B" in code), then I would not create a dedicated branch for that (or at least, I would use a fast forward for merge)
  • the hotfix needs quite a lot of work, and then creating a branch to hold those devs is a good way to ease review and identifying all work that was pulled by this bug fix. This could help performing non regression tests later.

If you are owner of your git repo, you may also "rewrite history" by suppressing the merge of the "almost good" feature, and fix the feature to re-merge it later on. This is usually not praised as "changing the history" but if you are just a few developper on the code and everybody is fine with it, that is a possibility.