Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


hotfix finish should back merge into release branch #177

jeroenhouben opened this Issue · 13 comments


I think it would be nice if "git flow hotfix finish" would merge back into the release branch, if there is one. I think it makes sense for the release branch to automatically obtain the latest hotfixes. Or am I overlooking something? Is this something you can currently do with git flow?


Taken from under "Finishing a hotfix branch"

"The one exception to the rule here is that, when a release branch currently exists, the hotfix changes need to be merged into that release branch, instead of develop. Back-merging the bugfix into the release branch will eventually result in the bugfix being merged into develop too, when the release branch is finished. (If work in develop immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into develop now already as well.)"


So, I guess most people are happy to either:

a) manually merge hotfixes into the release branch, if there is one, or,

b) rest assured that when they merge the release into master and develop, they wont accidentally resolve conflicts with theirs instead of ours?

Thoughts? Beuller?


I came here hoping to find this issue open. I'm sad to see it's gone stale. I'm even sadder to see that if someone were managing this repo it would be closed as a duplicate of #3 (just as #61) was.

Anyway, this is my only problem with using git flow. I'm constantly forgetting to merge hotfixes back into our existing release branch.


My question about this request is: how to determine on which release branch the hotfix should apply?

You can't just assume the latest, well I guess you could but that could lead to all sorts of problems. What if there is no unreleased released branch and you keep the released release branches?


Might as well do all of them. If the user doesn't want to, they can stop the merge manually. I'm more curious to know how many release branches ppl create at once and why. We never have more than one.


I agree with you that I don't see the point of creating multiple release branches, but git flow release has the option to keep release branches. So it's not a release branch in progress, it's a finished release kept for what ever reason. So you can't just apply a hotfix to all of them.

I guess you could solve this with a hook script, post-flow-hotfix-finish. This script would be called at the end of the git flow hotfix finish command. These hook calls have been implemented in my fork

In that script you could do a git merge in your release branch.
Quick and dirty:

# Runs at the end of git flow hotfix finish
# Positional arguments:
# $1    The version (including the version prefix)
# $2    The origin remote
# $3    The full branch name (including the feature prefix)

# Implement your script here.

RELEASE_PREFIX=$(git config --get gitflow.prefix.release)

# Get the release branch with the latest commit date.
RELEASE_BRANCH=$(git for-each-ref --sort=-committerdate refs/heads/$RELEASE_PREFIX --format='%(refname:short)' --count=1)

git checkout $RELEASE_BRANCH
git merge --no-ff "$BRANCH" || die "There were merge conflicts."

exit 0

This isn't perfect, for one if the merge fails the hotfix branch will be deleted. You could compensate with keeping the hotfix branch.

Is this a better option as adding another flag to the hotfix command?


I am having issues with this as well as I've ended up releasing with hotfixes missing because they aren't being merged into the ongoing release.

The point about "which release branch to merge into"; doesn't git flow say that there should only be one ongoing release branch at a time? For example; if I try and start a new release whilst I already have one ongoing, git flow will error saying that I need to finish the current release (i.e. merge and delete the branch). So couldn't the behaviour be that - when finishing a hotfix - if:

  • A single release branch currently exists; then that is merged in to and not straight to develop
  • Multiple release branches exist; then fail with a message indicating that it's unknown where to merge the hotfix since multiple releases are ongoing
  • No release branches exist; merge into develop as normal

Maybe the flag to override all of that is to just skip the automatic merge all together and allow the user to do that, which would allow for these different scenarios.

I know some people may want to keep release branches around, but that would break other points in the flow using standard options, so why not this as well?


I completely agree with @dcopestake. It is the obvious solution and git-flow should have been built this way from the start if it was intended to match Driessen's post from 05 Jan 2010.

I was so bothered by this missing detail from git-flow that I created an updated git-flow-ish diagram to remind us where hotfixes need to go during release development. It is published here:

BTW, this is NOT a duplicate of #3. It is, however, a duplicate of #61 (which was incorrectly closed as a dupe of #3).


+1 just ran into this issue, agree with @dcopestake and @juanitogan
hotfix branch should merge into release branch, if available.

@milesibastos milesibastos referenced this issue from a commit in milesibastos/gitflow
@petervanderdoes petervanderdoes Update with changes since previous version.
Fixes: #177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.