Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In git-flow, why does master even exist?

Tags:

git

git-flow

I was discussing git-flow with my coworkers and they brought up an interesting point. Why not tag releases off of develop instead of master? Master seems to exist for the sole purpose of tags. Maybe I missed something obvious when I read the entire article for git-flow.

like image 218
void.pointer Avatar asked Jan 29 '14 20:01

void.pointer


People also ask

Why does Git use master?

In Git, "master" is a naming convention for a branch. After cloning (downloading) a project from a remote server, the resulting local repository has a single local branch: the so-called "master" branch. This means that "master" can be seen as a repository's "default" branch.

Why does Git say my master branch is already up to date even though it is not?

If the current branch is not outdated compared to the one you pull from, pull will say Already up-to-date. even if you have local changes in your working directory. git pull is concerned with branches, not the working tree — it will comment on the working tree only if there are changes which interfere with the merge.

Is it mandatory to have master branch in Git?

No, the main branch can be any branch you want. By default, when you create a repository, the main branch is named the master branch. It is the base branch or the default branch. You can go through How to set up default branches in Git to know more.

How many master branches does the Git workflow user?

Instead of a single main branch, this workflow uses two branches to record the history of the project. The main branch stores the official release history, and the develop branch serves as an integration branch for features.


2 Answers

You cannot simply tag develop for 2 reasons: release branches and hotfixes branches.

release branches - once you create your release branch from develop to prepare for a release, then you have your "release candidate" that will only get limited changes while the main development branch develop may continue to get additional commits not intended for this release, e.g. changes intended for a future release. Even if you merge the changes from the release branch into develop, you will still have additional commits on develop that aren't intended for release, i.e. you can't tag develop. Also note that release branches are temporary branches that go away after release while master (and develop) are long-lived "permanent" branches.

hotfix branches - A similar situation exists for a hotfix - you create a hotfix temporary branch (from your last release) to allow you to isolate which commits go into your hotfix release (just specific bugfixes).

You could tag the final commits of the release branches and hotfix branches and/or make those branches long-lived branches, but git-flow model uses master to track and connect the releases.

like image 123
Bert F Avatar answered Oct 23 '22 00:10

Bert F


master exists by convention. If you want to establish a different convention you can. the idea of a master branch may or may not suite your purposes.

like image 3
Maus Avatar answered Oct 22 '22 23:10

Maus