12

I've started using gitflow for a project, and I have an outstanding feature branch as well as a newly created hotfix. Per the gitflow workflow, the hotfix gets applied to both the master and develop branches, but nothing is said or done about extant feature branches.

Nevertheless, I'd like to incorporate the hotfix changes back into my feature branch, which as near as I can tell leaves three options:

  1. Don't incorporate the changes. If the changes were needed for the feature branch, it should've been part of the feature branch.
  2. Merge develop back into the feature branch. This seems to follow the gitflow workflow the best, but would cause out-of-order commits.
  3. Rebase the feature branch onto develop. This would preserve commit order but rebasing seems to be completely absent from the general gitflow workflow.

What's the best practice here?

2
  • Feature branches are generally supposed to be very short-lived, it's kind of an SCM smell to be merging changes into them; is it impossible to just finish (or stabilize) the feature branch and merge it back?
    – Aaronaught
    Sep 2, 2012 at 0:54
  • 2
    @Aaronaught well the feature's not done/may go nowhere. The basic situation is that a feature that's taking a couple of days to develop uncovered a bug that could potentially affect production data. Tests were written, hotfix applied to master/production, but the unfinished feature is still broken by the bug. Are you suggesting merging a half-completed feature into the development mainline? What happens if the feature doesn't pan out?
    – user8
    Sep 2, 2012 at 1:01

1 Answer 1

13

I don't see anything wrong with rebasing your feature branch onto develop to pick up the latest hot fixes. Actually, frequently rebasing your feature branch against develop can be helpful, since it lets you keep your branch "up to date," which makes merging much easier when you get to that stage.

2
  • Yeah: looking around some more, circumstantial evidence—including the gitflow 0.2 announcement which added feature rebasing—is pointing to the regular git rebase workflow being the gitflow workflow as well.
    – user8
    Sep 2, 2012 at 1:52
  • 2
    Interesting. I can't say I'm an expert on Gitflow, but my understanding was hotfix's were singular commits against master, not branches, and I simply cherry picked them to develop. Reading up thought I was totally wrong on that.
    – jb510
    Aug 15, 2014 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.