Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Following git-flow how should you handle a hotfix of an earlier release?

If you try to follow the git-flow branching model, documented here and with tools here, how should you handle this situation:

You have made a 1.0 release and a 2.0 release. Then you need to make a hotfix for 1.0. You create a hotfix branch off the 1.0 tag and implement the fix there. But what then?

Normally you would merge to master and put a 1.1 release tag there. But you can't merge 1.1 to a point after 2.0 on master.

I guess you could put the release tag on the hotfix branch, but that would create a permanent branch beside the master that would contain a release tag. Is that the right way?

like image 580
Klas Mellbourn Avatar asked May 05 '13 15:05

Klas Mellbourn


People also ask

How does hotfix work in git?

Properties of the Gitflow hotfix No feature enhancements or chores are allowed on the Gitflow hotfix branch. The hotfix branch merges into both master and develop branches when its lifecycle ends. The hotfix branch is deleted after it is merged or rebased into master and develop branches.

What branch or branches is a hotfix branch merged into in a Gitflow workflow?

Hotfix branches As soon as the fix is complete, it should be merged into both main and develop (or the current release branch), and main should be tagged with an updated version number. Similar to finishing a release branch, a hotfix branch gets merged into both main and develop.

What does git flow release do?

Gitflow release branch process overview The release branch represents a complete feature set. The only commits on the release branch are for bug fixes and important chores. The Gitflow release branch is created off the development branch. Gitflow release is merged into master and also back into development.

What is git flow process?

Git flow is a popular Git branching strategy aimed at simplifying release management, and was introduced by software developer Vincent Driessen in 2010. Fundamentally, Git flow involves isolating your work into different types of Git branches.


2 Answers

It seems that there is a concept of a "support" branch in git flow. This is used to add a hotfix to an earlier release.

This thread has more information, with these examples:

git checkout 6.0 git checkout -b support/6.x git checkout -b hotfix/6.0.1 

... make your fix, then:

git checkout support/6.x git merge hotfix/6.0.1 git branch -d hotfix/6.0.1 git tag 6.0.1 

or using git flow commands

git flow support start 6.x 6.0 git flow hotfix start 6.0.1 support/6.x 

... make changes then:

git flow hotfix finish 6.0.1 
like image 196
Klas Mellbourn Avatar answered Sep 24 '22 19:09

Klas Mellbourn


Interesting question! The flow you linked assumes master can track production. That only works if production versions are strictly increasing. That's typically true for a website which has only one production version.

If you have to maintain multiple production versions, one branch to track production is not enough. A solution is not to use master to track production. Instead, use branches like release1, release2, etc.

In this approach, you may not even need a hotfix branch. You could fix the problem on the release1 branch. When the fix is good enough, create a release1.1 tag on the release1 branch.

like image 22
Andomar Avatar answered Sep 22 '22 19:09

Andomar