Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitflow why do we need master

Tags:

git

git-flow

in gitflow all release branches are eventually

  1. merge to master
  2. merge to develop
  3. tag master
  4. delete the release branch

but why don't we just

  1. tag the release branch
  2. merge to develop
  3. delete the release branch

in case of hotfix we can just

  1. branch of the latest tag
  2. do the hotfix
  3. tag that hot fix branch
  4. merge to develop
  5. delete the hotfix branch
like image 240
Mahmoud Adel Farid Avatar asked Apr 26 '18 02:04

Mahmoud Adel Farid


People also ask

Why do we need master branch Git?

A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master . As you start making commits, you're given a master branch that points to the last commit you made. Every time you commit, the master branch pointer moves forward automatically.

Why is Gitflow important?

Git Flow Workflow simplifies parallel development because it isolates the new development from the released project. You can work on any project version. The new development is done in feature branches so it is merged back when the developer is satisfied with the code.

Is master branch compulsory in Git?

Most Git repositories use master as the main (and default) branch - if you initialize a new Git repo via git init , it will have master checked out by default.

What is the purpose of master branch?

One word: the master branch is deployable. It is your production code, ready to roll out into the world. The master branch is meant to be stable, and it is the social contract of open source software to never, ever push anything to master that is not tested, or that breaks the build.


1 Answers

You are almost describing a release-flow branching model:

  • Developers merge with a common mainline branch (call it develop or master)
  • When you are ready to release branch from mainline (call it release/r-1.2 etc)
  • When you find an issue with the new release create a hotfix branch (hotfix/fix-something)
  • Merge your hotfix into your mainline as you would ordinary dev
  • Merge/cherry pick the hotfix into your release branch
  • The release branch represents production when it is deployed to that environment

There is no final merge to a production branch - its not needed as the release branch is the same thing.

Once an old release branch has been superceeded by the next one it can be deleted if no longer required for audit purposes.

This is documented well by the VSTS team: https://docs.microsoft.com/en-gb/azure/devops/devops-at-microsoft/release-flow

like image 148
James Avatar answered Sep 22 '22 14:09

James