Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix finish should back merge into release branch #177

Open
jeroenhouben opened this issue Dec 20, 2011 · 28 comments · Fixed by CJ-Systems/gitflow-cjs#71
Open

hotfix finish should back merge into release branch #177

jeroenhouben opened this issue Dec 20, 2011 · 28 comments · Fixed by CJ-Systems/gitflow-cjs#71

Comments

@jeroenhouben
Copy link

Hi,

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?

@jeroenhouben
Copy link
Author

Taken from http://nvie.com/posts/a-successful-git-branching-model/ 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.)"

@AckermanMD
Copy link

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?

@pcg79
Copy link

pcg79 commented May 31, 2012

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.

@petervanderdoes
Copy link

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?

@pcg79
Copy link

pcg79 commented May 31, 2012

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.

@petervanderdoes
Copy link

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
https://github.com/petervanderdoes/gitflow

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

#!/bin/sh
#
# 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)
#
VERSION=$1
ORIGIN=$2
BRANCH=$3

# 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?

@dcopestake
Copy link

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?

@andreaskern
Copy link

+1

1 similar comment
@masimplo
Copy link

masimplo commented Oct 6, 2014

+1

@juanitogan
Copy link

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:
https://www.lucidchart.com/community/software/git-flow-flipped-/8993117e-878b-4817-b9cd-ad07ea2f38d9

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

@michalmikolajczyk
Copy link

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

@tothsanka
Copy link

+1

1 similar comment
@digitalgears
Copy link

+1

milesibastos pushed a commit to milesibastos/gitflow that referenced this issue Apr 16, 2015
@benpriestman
Copy link

+1

4 similar comments
@borice
Copy link

borice commented May 21, 2015

+1

@andreacremaschi
Copy link

+1

@leocalzavara
Copy link

+1

@dools
Copy link

dools commented Jul 15, 2015

+1

@raveren
Copy link

raveren commented Jul 23, 2015

Is this critical issue seriously open after four years?

@raveren
Copy link

raveren commented Jul 23, 2015

oh, the project is abandoned, use https://github.com/petervanderdoes/gitflow instead of this one.

@tothsanka
Copy link

LOL 👍 for @raveren

@srt32
Copy link

srt32 commented Jul 23, 2015

@tothsanka @raveren mind making some noise on #419, which I opened in an attempt to get the README updated to include the unmaintained status of this project.

@Grendel61
Copy link

Actually I just tested this process, and it works the way you would hope. I think the key is how you start the hotfix. I started with:

git flow hotfix start [hotfix name] release/[release name]

I used the whole branch name (e.g. release/[release name] which may not be required).

This set up the references appropriately from the start. Then I did a:
git flow hotfix finish (hotfix name)

This only merged the changes into the release branch. On Github we set our default branch to the Release so that we don't inadvertently merge into master or develop. I checked master and develop both locally and on my remote and neither were populated by the "finish".

Carefully squeezing the release name into the "hotfix start" is extra work, but it takes care of a number of git commands.

Hope this helps.

@mystcreater
Copy link

mystcreater commented Jul 24, 2017

+1 :)

@stralytic
Copy link

+100

@emannuel
Copy link

+1

@Regenhardt
Copy link

Amazing, an open issue almost as old as the original blog post itself. The flow is a de-facto standard by now, would be nice to have a single de-facto-official repository with old ones referencing it.

@ChrisJStone
Copy link

Amazing, an open issue almost as old as the original blog post itself. The flow is a de-facto standard by now, would be nice to have a single de-facto-official repository with old ones referencing it.

See gitflow-cjs for maintained fork

ChrisJStone pushed a commit to CJ-Systems/gitflow-cjs that referenced this issue Jul 5, 2023
Add new option releaseBackMerge to git flow hotfix finish when there is
an existing release on a remote repository we can now backmerge the
hotfix onto the release branch as well as develop and master.

Origional author of PR: Bankers, R.H.M. (Rob) <rob.bankers@sns.nl>

closes nvie/gitflow#177 and closes petervanderdoes/gitflow-avh#161
ChrisJStone added a commit to CJ-Systems/gitflow-cjs that referenced this issue Jul 5, 2023
Add new option releaseBackMerge to git flow hotfix finish when there is
an existing release on a remote repository we can now backmerge the
hotfix onto the release branch as well as develop and master.

closes #69 
closes nvie/gitflow#177 
closes petervanderdoes/gitflow-avh#161
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.