Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the git flow model should I build from the merge commit in master to release?

Tags:

git

git-flow

At my company we have a CI/Build server that we use to test and build releases (as well as features and the develop branch). In the git flow branching model when it is time to release you branch off develop and name it (for instance) release-1.4. The CI/Build server would then automatically build the branch and we would deploy it to a staging server for manual integration testing. Once we are satisfied with the build we would like to deploy it. But in the git flow branching model we need to merge to master and tag first. The question is, do we need to run another build and test cycle after this merge or what?

It seems weird to merge and tag ending up with the tag pointing at a different (technically) commit than the release was built off of. It also seems bad to rebuild after we get into master because we would then feel compelled to test that build to make sure it is ok too.

The options I've come up with are:

  • build in the release branch and then merge and rebuild and test in the master branch
  • build and test in the release branch then merge and trust that no new build is needed
  • Modify the git flow model to remove the step of merging to master and just tag the final commit in the release branch that we want to release.
    • What would be lost by not merging to master?
    • In this case we could probably just develop in master
like image 352
thephred Avatar asked Nov 06 '13 21:11

thephred


People also ask

Should you squash commits when merging into master?

As a general rule, when merging a pull request from a feature branch with a messy commit history, you should squash your commits. There are exceptions, but in most cases, squashing results in a cleaner Git history that's easier for the team to read.

Should I merge release branch to develop?

Once all the testing is completed and it is ready to be promoted in production then you need to first merge your release branch with master and then later with develop. So the next time, when you are working on a hotfix or on a release or feature then you can start working by just creating a branch from develop.

Which branch should be used for bringing forth production releases git flow?

A separate merge of the Gitflow release branch into the develop branch is also required. This ensures that any fixes made to the release after the initial branching make it back into development. The Gitflow release branch is made from the develop branch and gets merged into both master and develop when finished.


1 Answers

The question is, do we need to run another build and test cycle after this merge or what?

That merge shouldn't break anything because it should be a fast-forward merge, all the commits on master are on the release branch. Therefore, you can not create a bug on master post-merge that wasn't on the release branch.

So technically yes, it isn't the precise commit you built, but the philosophy is that everything on the master branch is in production. At anytime, if someone pulls the master branch he should get the current production code. That's why you don't merge and then build, and test, and wait, and fix things on master for a release.

Now things does not always go smoothly. By the time the release has been validated and is ready to ship, you may have encounter major production bugs that needed a hotfix, in that case some commits have been pushed to master and develop but not to the release branch. If this happens, I'd rebase (be careful with that when working in team, merge is safer) the release branch on develop (to catch up with the hotfixes) and rebuild again. To sum up, if there are no hotfixes between the time the release branch was created and the time it is validated, no need to rebuild.

like image 79
Joucks Avatar answered Oct 25 '22 15:10

Joucks